(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
authorglx
Tue, 05 Sep 2006 16:40:23 +0000
changeset 4556 693f37c36c85
parent 4555 19987258e62d
child 4557 112872feb6fd
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
rail_cmd.c
train_cmd.c
--- a/rail_cmd.c	Tue Sep 05 13:39:38 2006 +0000
+++ b/rail_cmd.c	Tue Sep 05 16:40:23 2006 +0000
@@ -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 @@
 		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);
+				}
+			}
 		}
 	}
 
--- a/train_cmd.c	Tue Sep 05 13:39:38 2006 +0000
+++ b/train_cmd.c	Tue Sep 05 16:40:23 2006 +0000
@@ -113,6 +113,7 @@
 	if (v->u.rail.cached_power != power) {
 		v->u.rail.cached_power = power;
 		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 	}
 }