(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.

This commit is contained in:
michi_cc 2009-08-10 23:52:40 +00:00
parent 0f3aa56bea
commit 6c88e22cc7

View File

@ -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) {