From b84e93487f39e5c8cb336c1723fbab0bf2ff3062 Mon Sep 17 00:00:00 2001 From: michi_cc Date: Mon, 10 Aug 2009 23:52:44 +0000 Subject: (svn r17152) -Fix: A stuck train could free the reservation of another train if it was reversed or did crash. --- src/train_cmd.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/train_cmd.cpp') 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)) { -- cgit v1.2.3-54-g00ecf