From da18471d48e0345499d9b819b86486ea8761902a Mon Sep 17 00:00:00 2001 From: michi_cc Date: Mon, 10 Aug 2009 23:52:40 +0000 Subject: (svn r17151) -Fix [FS#3104] (r13974): A train entering a PBS section through a block signal could cause a train crash if another reservation ending at a safe tile was already present in the section. --- src/train_cmd.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/train_cmd.cpp') diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index b0cb85ff4..4505c6abd 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3150,6 +3150,15 @@ bool TryPathReserve(Train *v, bool mark_as_stuck, bool first_tile_okay) bool other_train = false; PBSTileInfo origin = FollowTrainReservation(v, &other_train); + /* The path we are driving on is alread blocked by some other train. + * This can only happen in certain situations when mixing path and + * block signals or when changing tracks and/or signals. + * Exit here as doing any further reservations will probably just + * make matters worse. */ + if (other_train && v->tile != origin.tile) { + if (mark_as_stuck) MarkTrainAsStuck(v); + return false; + } /* If we have a reserved path and the path ends at a safe tile, we are finished already. */ if (origin.okay && (v->tile != origin.tile || first_tile_okay)) { /* Can't be stuck then. */ @@ -3157,14 +3166,6 @@ bool TryPathReserve(Train *v, bool mark_as_stuck, bool first_tile_okay) ClrBit(v->flags, VRF_TRAIN_STUCK); return true; } - /* The path we are driving on is alread blocked by some other train. - * This can only happen when tracks and signals are changed. A crash - * is probably imminent, don't do any further reservation because - * it might cause stale reservations. */ - if (other_train && v->tile != origin.tile) { - if (mark_as_stuck) MarkTrainAsStuck(v); - return false; - } /* If we are in a depot, tentativly reserve the depot. */ if (v->track == TRACK_BIT_DEPOT) { -- cgit v1.2.3-54-g00ecf