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:
Michael Lutz 2025-06-15 22:09:04 +02:00 committed by GitHub
parent 98b488f366
commit e163aab892
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 3 deletions

View File

@ -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 */

View File

@ -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;