mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
616370eae3
commit
da18471d48
|
@ -3150,6 +3150,15 @@ bool TryPathReserve(Train *v, bool mark_as_stuck, bool first_tile_okay)
|
||||||
|
|
||||||
bool other_train = false;
|
bool other_train = false;
|
||||||
PBSTileInfo origin = FollowTrainReservation(v, &other_train);
|
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 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)) {
|
if (origin.okay && (v->tile != origin.tile || first_tile_okay)) {
|
||||||
/* Can't be stuck then. */
|
/* 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);
|
ClrBit(v->flags, VRF_TRAIN_STUCK);
|
||||||
return true;
|
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 we are in a depot, tentativly reserve the depot. */
|
||||||
if (v->track == TRACK_BIT_DEPOT) {
|
if (v->track == TRACK_BIT_DEPOT) {
|
||||||
|
|
Loading…
Reference in New Issue