mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-18 19:19:29 +01:00
Fix: Train path reservations on different railtypes could join leading to train crashes. (#14366)
This could happen if the compatibility between the railtypes was not symmetric. If for example a reservation of a first train ended at a railtype transition with an already present reservation on the other side, a reversing train could end up crashing with the first train.
This commit is contained in:
parent
98b488f366
commit
e163aab892
@ -331,7 +331,7 @@ protected:
|
||||
}
|
||||
|
||||
/* rail transport is possible only on compatible rail types */
|
||||
if (IsRailTT()) {
|
||||
if (IsRailTT() && this->railtypes.Any()) {
|
||||
RailType rail_type = GetTileRailType(this->new_tile);
|
||||
if (!this->railtypes.Test(rail_type)) {
|
||||
/* incompatible rail type */
|
||||
|
@ -436,8 +436,9 @@ bool IsWaitingPositionFree(const Train *v, TileIndex tile, Trackdir trackdir, bo
|
||||
if (IsRailDepotTile(tile)) return true;
|
||||
if (IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, track))) return true;
|
||||
|
||||
/* Check the next tile, if it's a PBS signal, it has to be free as well. */
|
||||
CFollowTrackRail ft(v, GetRailTypeInfo(v->railtype)->compatible_railtypes);
|
||||
/* Check the next tile, it has to be free as well. Do not filter for compatible railtypes
|
||||
* to make sure we never accidentally join up reservations. */
|
||||
CFollowTrackRail ft(v, RailTypes{});
|
||||
|
||||
if (!ft.Follow(tile, trackdir)) return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user