From 0dd0bbc0717a62fab93a3279085b7a609526725e Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 2 Jan 2013 22:20:07 +0000 Subject: (svn r24882) -Fix: desync when NewGRF changes the stats related to acceleration (power, weight, tractive effort, etc) during service or 32 day triggers --- src/economy.cpp | 3 +++ src/vehicle.cpp | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/economy.cpp b/src/economy.cpp index 92f9a0cd5..cfb5a4ea1 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1637,6 +1637,9 @@ static void LoadUnloadVehicle(Vehicle *front, int *cargo_left) front->load_unload_ticks = max(1, unloading_time); if (completely_emptied) { + /* Make sure the vehicle is marked dirty, since we need to update the NewGRF + * properties such as weight, power and TE whenever the trigger runs. */ + assert(dirty_vehicle); TriggerVehicle(front, VEHICLE_TRIGGER_EMPTY); } diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 27b5e4b30..2eef611ac 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -836,7 +836,11 @@ static void RunVehicleDayProc() if ((v->day_counter & 0x1F) == 0 && v->HasEngineType()) { uint16 callback = GetVehicleCallback(CBID_VEHICLE_32DAY_CALLBACK, 0, 0, v->engine_type, v); if (callback != CALLBACK_FAILED) { - if (HasBit(callback, 0)) TriggerVehicle(v, VEHICLE_TRIGGER_CALLBACK_32); // Trigger vehicle trigger 10 + if (HasBit(callback, 0)) { + /* After a vehicle trigger, the graphics and properties of the vehicle could change. */ + TriggerVehicle(v, VEHICLE_TRIGGER_CALLBACK_32); // Trigger vehicle trigger 10 + v->MarkDirty(); + } if (HasBit(callback, 1)) v->colourmap = PAL_NONE; if (callback & ~3) ErrorUnknownCallbackResult(v->GetGRFID(), CBID_VEHICLE_32DAY_CALLBACK, callback); @@ -1340,7 +1344,9 @@ void VehicleEnterDepot(Vehicle *v) VehicleServiceInDepot(v); + /* After a vehicle trigger, the graphics and properties of the vehicle could change. */ TriggerVehicle(v, VEHICLE_TRIGGER_DEPOT); + v->MarkDirty(); if (v->current_order.IsType(OT_GOTO_DEPOT)) { SetWindowDirty(WC_VEHICLE_VIEW, v->index); -- cgit v1.2.3-70-g09d2