diff options
author | michi_cc <michi_cc@openttd.org> | 2009-08-10 23:52:40 +0000 |
---|---|---|
committer | michi_cc <michi_cc@openttd.org> | 2009-08-10 23:52:40 +0000 |
commit | da18471d48e0345499d9b819b86486ea8761902a (patch) | |
tree | 30ee4b56ecd74a1699dffa49df38f5b7bffe7df9 /src | |
parent | 616370eae34993be4961e690f8c008085a5b33b9 (diff) | |
download | openttd-da18471d48e0345499d9b819b86486ea8761902a.tar.xz |
(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.
Diffstat (limited to 'src')
-rw-r--r-- | src/train_cmd.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
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) { |