summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2005-04-03 09:38:13 +0000
committerbjarni <bjarni@openttd.org>2005-04-03 09:38:13 +0000
commit587106a8692dec18a179c769aa114313645a7f77 (patch)
treefd65bea32ae800eceffa78c0d4503fb1da846af3
parent5d937e4a233757a49fc901f99be68b5f6a94e543 (diff)
downloadopenttd-587106a8692dec18a179c769aa114313645a7f77.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.c8
1 files changed, 4 insertions, 4 deletions
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);