summaryrefslogtreecommitdiff
path: root/src/pbs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pbs.cpp')
-rw-r--r--src/pbs.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/pbs.cpp b/src/pbs.cpp
index 5c6a0fbcb..01e7b2f37 100644
--- a/src/pbs.cpp
+++ b/src/pbs.cpp
@@ -191,7 +191,21 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
TrackdirBits reserved = ft.m_new_td_bits & TrackBitsToTrackdirBits(GetReservedTrackbits(ft.m_new_tile));
/* No reservation --> path end found */
- if (reserved == TRACKDIR_BIT_NONE) break;
+ if (reserved == TRACKDIR_BIT_NONE) {
+ if (ft.m_is_station) {
+ /* Check skipped station tiles as well, maybe our reservation ends inside the station. */
+ TileIndexDiff diff = TileOffsByDiagDir(ft.m_exitdir);
+ while (ft.m_tiles_skipped-- > 0) {
+ ft.m_new_tile -= diff;
+ if (HasStationReservation(ft.m_new_tile)) {
+ tile = ft.m_new_tile;
+ trackdir = DiagDirToDiagTrackdir(ft.m_exitdir);
+ break;
+ }
+ }
+ }
+ break;
+ }
/* Can't have more than one reserved trackdir */
Trackdir new_trackdir = FindFirstTrackdir(reserved);