summaryrefslogtreecommitdiff
path: root/rail_cmd.c
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2006-09-05 16:40:23 +0000
committerglx <glx@openttd.org>2006-09-05 16:40:23 +0000
commitab5135dd3801278c750d80c72830e7eadfcf438c (patch)
tree45dd58459fce99a444dcbfe6d4ba4c0bf94ac317 /rail_cmd.c
parent75d8a724fa91d549a11c1ab02495bc2c54a21129 (diff)
downloadopenttd-ab5135dd3801278c750d80c72830e7eadfcf438c.tar.xz
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
Diffstat (limited to 'rail_cmd.c')
-rw-r--r--rail_cmd.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index 056578601..52a3bd058 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -31,6 +31,7 @@
#include "yapf/yapf.h"
#include "newgrf_callbacks.h"
#include "newgrf_station.h"
+#include "train.h"
const byte _track_sloped_sprites[14] = {
14, 15, 22, 13,
@@ -886,13 +887,23 @@ static int32 DoConvertRail(TileIndex tile, RailType totype, bool exec)
for (tracks = GetTrackBits(tile); tracks != TRACK_BIT_NONE; tracks = KILL_FIRST_BIT(tracks))
YapfNotifyTrackLayoutChange(tile, FIND_FIRST_BIT(tracks));
- /* Update build vehicle window related to this depot */
if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
- Window *w = FindWindowById(WC_BUILD_VEHICLE, tile);
+ Vehicle *v;
+ Window *w;
+
+ /* Update build vehicle window related to this depot */
+ w = FindWindowById(WC_BUILD_VEHICLE, tile);
if (w != NULL) {
WP(w,buildtrain_d).railtype = totype;
SetWindowDirty(w);
}
+
+ /* update power of trains in this depot */
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == VEH_Train && IsFrontEngine(v) && v->tile == tile && v->u.rail.track == 0x80) {
+ TrainPowerChanged(v);
+ }
+ }
}
}