summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2009-08-10 23:52:44 +0000
committermichi_cc <michi_cc@openttd.org>2009-08-10 23:52:44 +0000
commitb84e93487f39e5c8cb336c1723fbab0bf2ff3062 (patch)
tree6d2fd8719c024cec333a59b76b3f10e689c9b6e3 /src/train_cmd.cpp
parentda18471d48e0345499d9b819b86486ea8761902a (diff)
downloadopenttd-b84e93487f39e5c8cb336c1723fbab0bf2ff3062.tar.xz
(svn r17152) -Fix: A stuck train could free the reservation of another train if it was reversed or did crash.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 4505c6abd..a3ed9d30b 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1910,8 +1910,8 @@ static void ReverseTrainDirection(Train *v)
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
}
- /* Clear path reservation in front. */
- FreeTrainTrackReservation(v);
+ /* Clear path reservation in front if train is not stuck. */
+ if (!HasBit(v->flags, VRF_TRAIN_STUCK)) FreeTrainTrackReservation(v);
/* Check if we were approaching a rail/road-crossing */
TileIndex crossing = TrainApproachingCrossingTile(v);
@@ -3510,11 +3510,10 @@ static void SetVehicleCrashed(Train *v)
{
if (v->crash_anim_pos != 0) return;
- /* Free a possible path reservation and try to mark all tiles occupied by the train reserved. */
if (v->IsFrontEngine()) {
- /* Remove all reservations, also the ones currently under the train
- * and any railway station paltform reservation. */
- FreeTrainTrackReservation(v);
+ /* Remove the reserved path in front of the train if it is not stuck.
+ * Also clear all reserved tracks the train is currently on. */
+ if (!HasBit(v->flags, VRF_TRAIN_STUCK)) FreeTrainTrackReservation(v);
for (const Train *u = v; u != NULL; u = u->Next()) {
ClearPathReservation(u, u->tile, u->GetVehicleTrackdir());
if (IsTileType(u->tile, MP_TUNNELBRIDGE)) {