yapf/unittest/test_yapf.h
changeset 3914 f5118020cd84
parent 3900 4984308f9125
child 3971 2116cd6db7fd
--- a/yapf/unittest/test_yapf.h	Mon May 29 17:33:39 2006 +0000
+++ b/yapf/unittest/test_yapf.h	Mon May 29 18:39:42 2006 +0000
@@ -132,9 +132,9 @@
 template <class Types>
 struct CYapfTestBaseT
 {
-	typedef typename Types::Tpf Tpf;
+	typedef typename Types::Tpf Tpf;              ///< the pathfinder class (derived from THIS class)
 	typedef typename Types::NodeList::Titem Node; ///< this will be our node type
-	typedef typename Node::Key Key;    ///< key to hash tables
+	typedef typename Node::Key Key;               ///< key to hash tables
 	typedef typename Types::Map Map;
 
 	int m_x1, m_y1;
@@ -155,9 +155,13 @@
 		m_td1 = td1;
 	}
 
+	/// to access inherited path finder
 	Tpf& Yapf() {return *static_cast<Tpf*>(this);}
 	FORCEINLINE char TransportTypeChar() const {return 'T';}
 
+	/** 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) */
 	FORCEINLINE void PfFollowNode(Node& org)
 	{
 		int x_org = org.m_key.m_x;
@@ -191,6 +195,7 @@
 		}
 	}
 
+	/// Called when YAPF needs to place origin nodes into open list
 	FORCEINLINE void PfSetStartupNodes()
 	{
 		Node& n1 = Yapf().CreateNewNode();
@@ -201,6 +206,9 @@
 		Yapf().AddStartupNode(n1);
 	}
 
+	/** 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 */
 	FORCEINLINE bool PfCalcCost(Node& n)
 	{
 		// base tile cost depending on distance
@@ -216,6 +224,8 @@
 		return true;
 	}
 
+	/** 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 */
 	FORCEINLINE bool PfCalcEstimate(Node& n)
 	{
 		int dx = abs(n.m_key.m_x - m_x2);
@@ -227,6 +237,7 @@
 		return true;
 	}
 
+	/// Called by YAPF to detect if node ends in the desired destination
 	FORCEINLINE bool PfDetectDestination(Node& n)
 	{
 		bool bDest = (n.m_key.m_x == m_x2) && (n.m_key.m_y == m_y2);