summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-01-13 13:11:59 +0000
committersmatz <smatz@openttd.org>2008-01-13 13:11:59 +0000
commitb0c34f4d6275a0dc1b8639b5529e37233240f6e2 (patch)
treee364cfdba24a6176b9f1c3fab264d03b11cfd93d /src
parentcc52a56052a58e8566bbc04693c7ac8b66d033f1 (diff)
downloadopenttd-b0c34f4d6275a0dc1b8639b5529e37233240f6e2.tar.xz
(svn r11831) -Fix: call TrainConsistChanged() when removing crashed train part to be consistent with saveload process
Diffstat (limited to 'src')
-rw-r--r--src/train_cmd.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index efa820cc1..1bbec7cb1 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -3107,6 +3107,8 @@ reverse_train_direction:
*/
static void DeleteLastWagon(Vehicle *v)
{
+ Vehicle *first = v->First();
+
/* Go to the last wagon and delete the link pointing there
* *u is then the one-before-last wagon, and *v the last
* one which will physicially be removed */
@@ -3114,14 +3116,23 @@ static void DeleteLastWagon(Vehicle *v)
for (; v->Next() != NULL; v = v->Next()) u = v;
u->SetNext(NULL);
- InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
- DeleteWindowById(WC_VEHICLE_VIEW, v->index);
- RebuildVehicleLists();
- InvalidateWindow(WC_COMPANY, v->owner);
- if (v->u.rail.track == TRACK_BIT_DEPOT) {
- InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
+ if (first == v) {
+ /* Removing front vehicle (the last to go) */
+ DeleteWindowById(WC_VEHICLE_VIEW, v->index);
+ InvalidateWindow(WC_COMPANY, v->owner);
+ } else {
+ /* Recalculate cached train properties */
+ TrainConsistChanged(first);
+ InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
+ /* Update the depot window if the first vehicle is in depot -
+ * if v == first, then it is updated in PreDestructor() */
+ if (first->u.rail.track == TRACK_BIT_DEPOT) {
+ InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
+ }
}
+ RebuildVehicleLists();
+
BeginVehicleMove(v);
EndVehicleMove(v);