yapf/yapf_destrail.hpp
changeset 3930 1c293cf92ab5
parent 3914 6bdd22b93698
child 4389 18d6ccfb5335
equal deleted inserted replaced
3929:8e921f7e032c 3930:1c293cf92ab5
    33 	Tpf& Yapf() {return *static_cast<Tpf*>(this);}
    33 	Tpf& Yapf() {return *static_cast<Tpf*>(this);}
    34 
    34 
    35 	/// Called by YAPF to detect if node ends in the desired destination
    35 	/// Called by YAPF to detect if node ends in the desired destination
    36 	FORCEINLINE bool PfDetectDestination(Node& n)
    36 	FORCEINLINE bool PfDetectDestination(Node& n)
    37 	{
    37 	{
    38 		bool bDest = IsTileDepotType(n.GetLastTile(), TRANSPORT_RAIL);
    38 		return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
       
    39 	}
       
    40 
       
    41 	/// Called by YAPF to detect if node ends in the desired destination
       
    42 	FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
       
    43 	{
       
    44 		bool bDest = IsTileDepotType(tile, TRANSPORT_RAIL);
    39 		return bDest;
    45 		return bDest;
    40 	}
    46 	}
    41 
    47 
    42 	/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
    48 	/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
    43 	*   adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
    49 	*   adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
    91 	}
    97 	}
    92 
    98 
    93 	/// Called by YAPF to detect if node ends in the desired destination
    99 	/// Called by YAPF to detect if node ends in the desired destination
    94 	FORCEINLINE bool PfDetectDestination(Node& n)
   100 	FORCEINLINE bool PfDetectDestination(Node& n)
    95 	{
   101 	{
       
   102 		return PfDetectDestination(n.GetLastTile(), n.GetLastTrackdir());
       
   103 	}
       
   104 
       
   105 	/// Called by YAPF to detect if node ends in the desired destination
       
   106 	FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
       
   107 	{
    96 		bool bDest;
   108 		bool bDest;
    97 		if (m_dest_station_id != INVALID_STATION) {
   109 		if (m_dest_station_id != INVALID_STATION) {
    98 			bDest = IsRailwayStationTile(n.GetLastTile())
   110 			bDest = IsRailwayStationTile(tile)
    99 				&& (GetStationIndex(n.GetLastTile()) == m_dest_station_id)
   111 				&& (GetStationIndex(tile) == m_dest_station_id)
   100 				&& (GetRailStationTrack(n.GetLastTile()) == TrackdirToTrack(n.GetLastTrackdir()));
   112 				&& (GetRailStationTrack(tile) == TrackdirToTrack(td));
   101 		} else {
   113 		} else {
   102 			bDest = (n.GetLastTile() == m_destTile)
   114 			bDest = (tile == m_destTile)
   103 				&& ((m_destTrackdirs & TrackdirToTrackdirBits(n.GetLastTrackdir())) != TRACKDIR_BIT_NONE);
   115 				&& ((m_destTrackdirs & TrackdirToTrackdirBits(td)) != TRACKDIR_BIT_NONE);
   104 		}
   116 		}
   105 		return bDest;
   117 		return bDest;
   106 	}
   118 	}
   107 
   119 
   108 	/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
   120 	/** Called by YAPF to calculate cost estimate. Calculates distance to the destination