diff options
author | michi_cc <michi_cc@openttd.org> | 2009-08-10 23:52:44 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2009-08-10 23:52:44 +0000 |
commit | b84e93487f39e5c8cb336c1723fbab0bf2ff3062 (patch) | |
tree | 6d2fd8719c024cec333a59b76b3f10e689c9b6e3 | |
parent | da18471d48e0345499d9b819b86486ea8761902a (diff) | |
download | openttd-b84e93487f39e5c8cb336c1723fbab0bf2ff3062.tar.xz |
(svn r17152) -Fix: A stuck train could free the reservation of another train if it was reversed or did crash.
-rw-r--r-- | src/train_cmd.cpp | 11 | ||||
-rw-r--r-- | src/water_cmd.cpp | 2 |
2 files changed, 6 insertions, 7 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)) { diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index d168f2df4..5a1d6cef6 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -805,7 +805,7 @@ static void FloodVehicle(Vehicle *v) /* FreeTrainTrackReservation() calls GetVehicleTrackdir() that doesn't like crashed vehicles. * In this case, v->direction matches v->u.rail.track, so we can do this (it wasn't crashed before) */ t->vehstatus &= ~VS_CRASHED; - FreeTrainTrackReservation(t); + if (!HasBit(t->flags, VRF_TRAIN_STUCK)) FreeTrainTrackReservation(t); t->vehstatus |= VS_CRASHED; } t->crash_anim_pos = 4000; // max 4440, disappear pretty fast |