mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-01-24 08:01:33 +00:00
(svn r5065) -CodeChange: [YAPF] Added PfDetectDestination(tile, trackdir) for trains (to be used by platform selection feature)
This commit is contained in:
parent
bf2fb59bf9
commit
76a8f036df
@ -165,7 +165,7 @@ public:
|
|||||||
|
|
||||||
RailType rail_type = GetTileRailType(tile, trackdir);
|
RailType rail_type = GetTileRailType(tile, trackdir);
|
||||||
|
|
||||||
bool target_seen = false;
|
bool target_seen = Yapf().PfDetectDestination(tile, trackdir);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
segment_cost += Yapf().OneTileCost(tile, trackdir);
|
segment_cost += Yapf().OneTileCost(tile, trackdir);
|
||||||
@ -177,7 +177,6 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// finish if we have reached the destination
|
// finish if we have reached the destination
|
||||||
target_seen = Yapf().PfDetectDestination(n);
|
|
||||||
if (target_seen) {
|
if (target_seen) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -237,6 +236,8 @@ public:
|
|||||||
trackdir = new_td;
|
trackdir = new_td;
|
||||||
tile_type = GetTileType(tile);
|
tile_type = GetTileType(tile);
|
||||||
|
|
||||||
|
target_seen = Yapf().PfDetectDestination(tile, trackdir);
|
||||||
|
|
||||||
// reversing in depot penalty
|
// reversing in depot penalty
|
||||||
if (tile == prev_tile) {
|
if (tile == prev_tile) {
|
||||||
segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
|
segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
|
||||||
|
@ -35,7 +35,13 @@ public:
|
|||||||
/// Called by YAPF to detect if node ends in the desired destination
|
/// Called by YAPF to detect if node ends in the desired destination
|
||||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||||
{
|
{
|
||||||
bool bDest = IsTileDepotType(n.GetLastTile(), TRANSPORT_RAIL);
|
return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by YAPF to detect if node ends in the desired destination
|
||||||
|
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||||
|
{
|
||||||
|
bool bDest = IsTileDepotType(tile, TRANSPORT_RAIL);
|
||||||
return bDest;
|
return bDest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,15 +98,21 @@ public:
|
|||||||
|
|
||||||
/// Called by YAPF to detect if node ends in the desired destination
|
/// Called by YAPF to detect if node ends in the desired destination
|
||||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
FORCEINLINE bool PfDetectDestination(Node& n)
|
||||||
|
{
|
||||||
|
return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called by YAPF to detect if node ends in the desired destination
|
||||||
|
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
|
||||||
{
|
{
|
||||||
bool bDest;
|
bool bDest;
|
||||||
if (m_dest_station_id != INVALID_STATION) {
|
if (m_dest_station_id != INVALID_STATION) {
|
||||||
bDest = IsRailwayStationTile(n.GetLastTile())
|
bDest = IsRailwayStationTile(tile)
|
||||||
&& (GetStationIndex(n.GetLastTile()) == m_dest_station_id)
|
&& (GetStationIndex(tile) == m_dest_station_id)
|
||||||
&& (GetRailStationTrack(n.GetLastTile()) == TrackdirToTrack(n.GetLastTrackdir()));
|
&& (GetRailStationTrack(tile) == TrackdirToTrack(td));
|
||||||
} else {
|
} else {
|
||||||
bDest = (n.GetLastTile() == m_destTile)
|
bDest = (tile == m_destTile)
|
||||||
&& ((m_destTrackdirs & TrackdirToTrackdirBits(n.GetLastTrackdir())) != TRACKDIR_BIT_NONE);
|
&& ((m_destTrackdirs & TrackdirToTrackdirBits(td)) != TRACKDIR_BIT_NONE);
|
||||||
}
|
}
|
||||||
return bDest;
|
return bDest;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user