(svn r5065) -CodeChange: [YAPF] Added PfDetectDestination(tile, trackdir) for trains (to be used by platform selection feature)
authorKUDr
Thu, 01 Jun 2006 21:00:59 +0000
changeset 3930 1c293cf92ab5
parent 3929 8e921f7e032c
child 3931 b946fc6e7188
(svn r5065) -CodeChange: [YAPF] Added PfDetectDestination(tile, trackdir) for trains (to be used by platform selection feature)
yapf/yapf_costrail.hpp
yapf/yapf_destrail.hpp
--- a/yapf/yapf_costrail.hpp	Thu Jun 01 09:43:39 2006 +0000
+++ b/yapf/yapf_costrail.hpp	Thu Jun 01 21:00:59 2006 +0000
@@ -165,7 +165,7 @@
 
 		RailType rail_type = GetTileRailType(tile, trackdir);
 
-		bool target_seen = false;
+		bool target_seen = Yapf().PfDetectDestination(tile, trackdir);
 
 		while (true) {
 			segment_cost += Yapf().OneTileCost(tile, trackdir);
@@ -177,7 +177,6 @@
 			}
 
 			// finish if we have reached the destination
-			target_seen = Yapf().PfDetectDestination(n);
 			if (target_seen) {
 				break;
 			}
@@ -237,6 +236,8 @@
 			trackdir = new_td;
 			tile_type = GetTileType(tile);
 
+			target_seen = Yapf().PfDetectDestination(tile, trackdir);
+
 			// reversing in depot penalty
 			if (tile == prev_tile) {
 				segment_cost += Yapf().PfGetSettings().rail_depot_reverse_penalty;
--- a/yapf/yapf_destrail.hpp	Thu Jun 01 09:43:39 2006 +0000
+++ b/yapf/yapf_destrail.hpp	Thu Jun 01 21:00:59 2006 +0000
@@ -35,7 +35,13 @@
 	/// Called by YAPF to detect if node ends in the desired destination
 	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;
 	}
 
@@ -93,14 +99,20 @@
 	/// Called by YAPF to detect if node ends in the desired destination
 	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;
 		if (m_dest_station_id != INVALID_STATION) {
-			bDest = IsRailwayStationTile(n.GetLastTile())
-				&& (GetStationIndex(n.GetLastTile()) == m_dest_station_id)
-				&& (GetRailStationTrack(n.GetLastTile()) == TrackdirToTrack(n.GetLastTrackdir()));
+			bDest = IsRailwayStationTile(tile)
+				&& (GetStationIndex(tile) == m_dest_station_id)
+				&& (GetRailStationTrack(tile) == TrackdirToTrack(td));
 		} else {
-			bDest = (n.GetLastTile() == m_destTile)
-				&& ((m_destTrackdirs & TrackdirToTrackdirBits(n.GetLastTrackdir())) != TRACKDIR_BIT_NONE);
+			bDest = (tile == m_destTile)
+				&& ((m_destTrackdirs & TrackdirToTrackdirBits(td)) != TRACKDIR_BIT_NONE);
 		}
 		return bDest;
 	}