File diff r4548:6a33e364fba5 → r4549:76b9213799ac
yapf/yapf_road.cpp
Show inline comments
 
@@ -61,14 +61,14 @@ protected:
 
		}
 
		return cost;
 
	}
 

	
 
public:
 
	/** Called by YAPF to calculate the cost from the origin to the given node.
 
	*   Calculates only the cost of given node, adds it to the parent node cost
 
	*   and stores the result into Node::m_cost member */
 
	 *  Calculates only the cost of given node, adds it to the parent node cost
 
	 *  and stores the result into Node::m_cost member */
 
	FORCEINLINE bool PfCalcCost(Node& n)
 
	{
 
		int segment_cost = 0;
 
		// start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment
 
		TileIndex tile = n.m_key.m_tile;
 
		Trackdir trackdir = n.m_key.m_td;
 
@@ -141,13 +141,13 @@ public:
 
	{
 
		bool bDest = IsTileDepotType(n.m_segment_last_tile, TRANSPORT_ROAD);
 
		return bDest;
 
	}
 

	
 
	/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	*   adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	FORCEINLINE bool PfCalcEstimate(Node& n)
 
	{
 
		n.m_estimate = n.m_cost;
 
		return true;
 
	}
 
};
 
@@ -183,13 +183,13 @@ public:
 
	{
 
		bool bDest = (n.m_segment_last_tile == m_destTile) && ((m_destTrackdirs & TrackdirToTrackdirBits(n.m_segment_last_td)) != TRACKDIR_BIT_NONE);
 
		return bDest;
 
	}
 

	
 
	/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
 
	*   adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	 *  adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
 
	inline bool PfCalcEstimate(Node& n)
 
	{
 
		static int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
 
		static int dg_dir_to_y_offs[] = {0, 1, 0, -1};
 
		if (PfDetectDestination(n)) {
 
			n.m_estimate = n.m_cost;
 
@@ -228,14 +228,14 @@ protected:
 
	/// to access inherited path finder
 
	FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
 

	
 
public:
 

	
 
	/** Called by YAPF to move from the given node to the next tile. For each
 
	*   reachable trackdir on the new tile creates new node, initializes it
 
	*   and adds it to the open list by calling Yapf().AddNewNode(n) */
 
	 *  reachable trackdir on the new tile creates new node, initializes it
 
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
 
	inline void PfFollowNode(Node& old_node)
 
	{
 
		TrackFollower F(Yapf().GetVehicle());
 
		if (F.Follow(old_node.m_segment_last_tile, old_node.m_segment_last_td))
 
			Yapf().AddMultipleNodes(&old_node, F.m_new_tile, F.m_new_td_bits);
 
	}