From 587106a8692dec18a179c769aa114313645a7f77 Mon Sep 17 00:00:00 2001 From: bjarni Date: Sun, 3 Apr 2005 09:38:13 +0000 Subject: (svn r2139) -fix: "[ 1146215 ] Engine power not updated w/auto replace" autoreplace now forces an update of the cache. It should not affect gameplay as the cache is updated each time the train starts moving, it's just an instant update of the detail window --- vehicle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'vehicle.c') diff --git a/vehicle.c b/vehicle.c index 884d435e1..6881faa4e 100644 --- a/vehicle.c +++ b/vehicle.c @@ -1307,7 +1307,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) the last 8 bit is the engine. The 8 bits in front of the engine is free so it have room for 16 bit engine entries */ uint16 new_engine_type = (uint16)(p2 & 0xFFFF); uint32 autorefit_money = (p2 >> 16) * 100000; - Vehicle *v, *u; + Vehicle *v, *u, *first; int cost, build_cost, rear_engine_cost = 0; byte old_engine_type; @@ -1349,6 +1349,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) return CMD_ERROR; if ( v->type == VEH_Train ) { + first = GetFirstVehicleInChain(v); u = GetLastVehicleInChain(v); if ( RailVehInfo(new_engine_type)->flags & RVI_MULTIHEAD ) build_cost = build_cost >> 1; //multiheaded engines have EstimateTrainCost() for both engines @@ -1357,7 +1358,6 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) // prevent that the rear engine can get replaced to something else than the front engine if ( v->u.rail.first_engine != 0xffff && RailVehInfo(old_engine_type)->flags & RVI_MULTIHEAD && RailVehInfo(old_engine_type)->flags ) { - Vehicle *first = GetFirstVehicleInChain(v); if ( first->engine_type != new_engine_type ) return CMD_ERROR; } @@ -1415,8 +1415,6 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) v->value = build_cost; - InvalidateWindow(WC_VEHICLE_DETAILS, v->index); - if (v->engine_type != new_engine_type) { byte sprite = v->spritenum; @@ -1493,6 +1491,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) } while ( (veh=veh->next) != NULL ); } InvalidateWindowClasses(WC_TRAINS_LIST); + UpdateTrainAcceleration(first); break; } case VEH_Road: @@ -1555,6 +1554,7 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) } InvalidateWindow(WC_REPLACE_VEHICLE, v->type); ResortVehicleLists(); + InvalidateWindow(WC_VEHICLE_DETAILS, v->index); } //needs to be down here because refitting will change SET_EXPENSES_TYPE if called SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES); -- cgit v1.2.3-70-g09d2