summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-01-08 12:47:54 +0000
committermichi_cc <michi_cc@openttd.org>2012-01-08 12:47:54 +0000
commit9232a2ef0c12efc6cd10f03487096c6dbf8727d3 (patch)
tree8f748b5632e8c76d3785eb000b9dbd451fa26e09 /src
parent7e78d15e58ae21e98fe6dfc515d05fb4c2f4c775 (diff)
downloadopenttd-9232a2ef0c12efc6cd10f03487096c6dbf8727d3.tar.xz
(svn r23773) -Change: [NewGRF] Update all cached train properties if a train vehicle enters a new railtype.
Diffstat (limited to 'src')
-rw-r--r--src/rail_cmd.cpp2
-rw-r--r--src/saveload/vehicle_sl.cpp3
-rw-r--r--src/train.h2
-rw-r--r--src/train_cmd.cpp19
4 files changed, 5 insertions, 21 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 49a58fe6d..1b60bfc6e 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -1658,7 +1658,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (flags & DC_EXEC) {
/* Railtype changed, update trains as when entering different track */
for (Train **v = affected_trains.Begin(); v != affected_trains.End(); v++) {
- (*v)->RailtypeChanged();
+ (*v)->ConsistChanged(true);
}
}
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 7c04448db..6087c347f 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -530,6 +530,9 @@ void FixupTrainLengths()
}
}
}
+
+ /* Update all cached properties after moving the vehicle chain around. */
+ Train::From(v)->ConsistChanged(true);
}
}
}
diff --git a/src/train.h b/src/train.h
index 6571544b0..80e8b3494 100644
--- a/src/train.h
+++ b/src/train.h
@@ -116,8 +116,6 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
void ConsistChanged(bool same_length);
- void RailtypeChanged();
-
int UpdateSpeed();
void UpdateAcceleration();
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index e17521ad6..f2ea70153 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -113,20 +113,6 @@ void CheckTrainsLengths()
}
/**
- * Update visual effect, power and acceleration caches.
- * Called when a vehicle in the consist enters a different railtype.
- */
-void Train::RailtypeChanged()
-{
- for (Train *u = this; u != NULL; u = u->Next()) {
- /* The wagon-is-powered-state should not change, so the weight does not change. */
- u->UpdateVisualEffect(false);
- }
- this->PowerChanged();
- if (this->IsFrontEngine()) this->UpdateAcceleration();
-}
-
-/**
* Recalculates the cached stuff of a train. Should be called each time a vehicle is added
* to/removed from the chain, and when the game is loaded.
* Note: this needs to be called too for 'wagon chains' (in the depot, without an engine)
@@ -1589,9 +1575,6 @@ void ReverseTrainSwapVeh(Train *v, int l, int r)
SwapTrainFlags(&a->gv_flags, &a->gv_flags);
UpdateStatusAfterSwap(a);
}
-
- /* Update power of the train in case tiles were different rail type. */
- v->RailtypeChanged();
}
@@ -3246,7 +3229,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
v->tile = gp.new_tile;
if (GetTileRailType(gp.new_tile) != GetTileRailType(gp.old_tile)) {
- v->First()->RailtypeChanged();
+ v->First()->ConsistChanged(true);
}
v->track = chosen_track;