mirror of https://github.com/OpenTTD/OpenTTD
(svn r23564) -Fix [FS#4888]: Extending a path reservation starting at a partially reserved rail station could fail.
parent
719b4707dc
commit
24b7be856b
|
@ -58,6 +58,7 @@ private:
|
||||||
Node *m_res_node; ///< The reservation target node
|
Node *m_res_node; ///< The reservation target node
|
||||||
TileIndex m_res_fail_tile; ///< The tile where the reservation failed
|
TileIndex m_res_fail_tile; ///< The tile where the reservation failed
|
||||||
Trackdir m_res_fail_td; ///< The trackdir where the reservation failed
|
Trackdir m_res_fail_td; ///< The trackdir where the reservation failed
|
||||||
|
TileIndex m_origin_tile; ///< Tile our reservation will originate from
|
||||||
|
|
||||||
bool FindSafePositionProc(TileIndex tile, Trackdir td)
|
bool FindSafePositionProc(TileIndex tile, Trackdir td)
|
||||||
{
|
{
|
||||||
|
@ -80,7 +81,7 @@ private:
|
||||||
SetRailStationReservation(tile, true);
|
SetRailStationReservation(tile, true);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
tile = TILE_ADD(tile, diff);
|
tile = TILE_ADD(tile, diff);
|
||||||
} while (IsCompatibleTrainStationTile(tile, start));
|
} while (IsCompatibleTrainStationTile(tile, start) && tile != m_origin_tile);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -145,9 +146,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Try to reserve the path till the reservation target. */
|
/** Try to reserve the path till the reservation target. */
|
||||||
bool TryReservePath(PBSTileInfo *target)
|
bool TryReservePath(PBSTileInfo *target, TileIndex origin)
|
||||||
{
|
{
|
||||||
m_res_fail_tile = INVALID_TILE;
|
m_res_fail_tile = INVALID_TILE;
|
||||||
|
m_origin_tile = origin;
|
||||||
|
|
||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
target->tile = m_res_dest;
|
target->tile = m_res_dest;
|
||||||
|
@ -359,7 +361,7 @@ public:
|
||||||
this->FindSafePositionOnNode(pPrev);
|
this->FindSafePositionOnNode(pPrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dont_reserve || this->TryReservePath(NULL);
|
return dont_reserve || this->TryReservePath(NULL, pNode->GetLastTile());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -452,7 +454,7 @@ public:
|
||||||
Node& best_next_node = *pPrev;
|
Node& best_next_node = *pPrev;
|
||||||
next_trackdir = best_next_node.GetTrackdir();
|
next_trackdir = best_next_node.GetTrackdir();
|
||||||
|
|
||||||
if (reserve_track && path_found) this->TryReservePath(target);
|
if (reserve_track && path_found) this->TryReservePath(target, pNode->GetLastTile());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Treat the path as found if stopped on the first two way signal(s). */
|
/* Treat the path as found if stopped on the first two way signal(s). */
|
||||||
|
|
16
src/pbs.cpp
16
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));
|
TrackdirBits reserved = ft.m_new_td_bits & TrackBitsToTrackdirBits(GetReservedTrackbits(ft.m_new_tile));
|
||||||
|
|
||||||
/* No reservation --> path end found */
|
/* 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 */
|
/* Can't have more than one reserved trackdir */
|
||||||
Trackdir new_trackdir = FindFirstTrackdir(reserved);
|
Trackdir new_trackdir = FindFirstTrackdir(reserved);
|
||||||
|
|
Loading…
Reference in New Issue