mirror of https://github.com/OpenTTD/OpenTTD
(svn r14876) -Fix [FS#2509] (r14849): Reserved path loop detection was broken for stations.
Don't set the test tile to the tile the very first iteration handles. Update the test tile instead in the loop.release/0.7
parent
c0efc759ef
commit
6138f6a2bb
23
src/pbs.cpp
23
src/pbs.cpp
|
@ -181,6 +181,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
|
||||||
{
|
{
|
||||||
TileIndex start_tile = tile;
|
TileIndex start_tile = tile;
|
||||||
Trackdir start_trackdir = trackdir;
|
Trackdir start_trackdir = trackdir;
|
||||||
|
bool first_loop = true;
|
||||||
|
|
||||||
/* Start track not reserved? This can happen if two trains
|
/* Start track not reserved? This can happen if two trains
|
||||||
* are on the same tile. The reservation on the next tile
|
* are on the same tile. The reservation on the next tile
|
||||||
|
@ -189,14 +190,6 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
|
||||||
|
|
||||||
/* Do not disallow 90 deg turns as the setting might have changed between reserving and now. */
|
/* Do not disallow 90 deg turns as the setting might have changed between reserving and now. */
|
||||||
CFollowTrackRail ft(o, rts);
|
CFollowTrackRail ft(o, rts);
|
||||||
|
|
||||||
/* If the start tile is in a station, we need to skip to the platform
|
|
||||||
* end and use that as the tile for the loop test because the track
|
|
||||||
* follower will skip to there in the actual loop as well. */
|
|
||||||
if (IsRailwayStationTile(start_tile) && ft.Follow(start_tile, start_trackdir) && ft.m_tiles_skipped > 0) {
|
|
||||||
start_tile = ft.m_new_tile;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (ft.Follow(tile, trackdir)) {
|
while (ft.Follow(tile, trackdir)) {
|
||||||
TrackdirBits reserved = ft.m_new_td_bits & TrackBitsToTrackdirBits(GetReservedTrackbits(ft.m_new_tile));
|
TrackdirBits reserved = ft.m_new_td_bits & TrackBitsToTrackdirBits(GetReservedTrackbits(ft.m_new_tile));
|
||||||
|
|
||||||
|
@ -213,8 +206,18 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra
|
||||||
tile = ft.m_new_tile;
|
tile = ft.m_new_tile;
|
||||||
trackdir = new_trackdir;
|
trackdir = new_trackdir;
|
||||||
|
|
||||||
/* Loop encountered? */
|
if (first_loop) {
|
||||||
if (tile == start_tile && trackdir == start_trackdir) break;
|
/* Update the start tile after we followed the track the first
|
||||||
|
* time. This is neccessary because the track follower can skip
|
||||||
|
* tiles (in stations for example) which means that we might
|
||||||
|
* never visit our original starting tile again. */
|
||||||
|
start_tile = tile;
|
||||||
|
start_trackdir = trackdir;
|
||||||
|
first_loop = false;
|
||||||
|
} else {
|
||||||
|
/* Loop encountered? */
|
||||||
|
if (tile == start_tile && trackdir == start_trackdir) break;
|
||||||
|
}
|
||||||
/* Depot tile? Can't continue. */
|
/* Depot tile? Can't continue. */
|
||||||
if (IsRailDepotTile(tile)) break;
|
if (IsRailDepotTile(tile)) break;
|
||||||
/* Non-pbs signal? Reservation can't continue. */
|
/* Non-pbs signal? Reservation can't continue. */
|
||||||
|
|
Loading…
Reference in New Issue