diff options
author | bjarni <bjarni@openttd.org> | 2005-04-03 09:38:13 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2005-04-03 09:38:13 +0000 |
commit | 19b87abd5680f408f1ca88993b3b56688c6454de (patch) | |
tree | fd65bea32ae800eceffa78c0d4503fb1da846af3 | |
parent | 816f629f13217fbcb6d57ca151f6727ccd7b1b03 (diff) | |
download | openttd-19b87abd5680f408f1ca88993b3b56688c6454de.tar.xz |
(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
-rw-r--r-- | vehicle.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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); |