diff options
author | KUDr <kudr@openttd.org> | 2006-05-29 18:39:42 +0000 |
---|---|---|
committer | KUDr <kudr@openttd.org> | 2006-05-29 18:39:42 +0000 |
commit | ed48b38619492a4018ac014d203718db689f69b2 (patch) | |
tree | cca7f9d507723ce078f410649f6ba598ccdb0523 /yapf/unittest | |
parent | 301f4ac856088ac32f89b791479fbb0dfb4f911b (diff) | |
download | openttd-ed48b38619492a4018ac014d203718db689f69b2.tar.xz |
(svn r5018) [YAPF] Added some comments to YAPF implementation.
Diffstat (limited to 'yapf/unittest')
-rw-r--r-- | yapf/unittest/test_yapf.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/yapf/unittest/test_yapf.h b/yapf/unittest/test_yapf.h index ca4b21de0..558ea4667 100644 --- a/yapf/unittest/test_yapf.h +++ b/yapf/unittest/test_yapf.h @@ -132,9 +132,9 @@ typedef CTestYapfNodeT<CNodeKey2> CYapfNode2; 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 @@ struct CYapfTestBaseT 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 @@ struct CYapfTestBaseT } } + /// Called when YAPF needs to place origin nodes into open list FORCEINLINE void PfSetStartupNodes() { Node& n1 = Yapf().CreateNewNode(); @@ -201,6 +206,9 @@ struct CYapfTestBaseT 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 @@ struct CYapfTestBaseT 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 @@ struct CYapfTestBaseT 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); |