diff options
author | KUDr <KUDr@openttd.org> | 2007-04-20 19:13:35 +0000 |
---|---|---|
committer | KUDr <KUDr@openttd.org> | 2007-04-20 19:13:35 +0000 |
commit | 1a7fec1894b859be9384e51e9a568b833cf1fb47 (patch) | |
tree | 1cf8985a250a13d94e9c28c82417f667b75b70a6 /src | |
parent | 52daf7a2d3ff456fd57f9403896e4f612bb7becc (diff) | |
download | openttd-1a7fec1894b859be9384e51e9a568b833cf1fb47.tar.xz |
(svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
Diffstat (limited to 'src')
-rw-r--r-- | src/yapf/yapf_base.hpp | 7 | ||||
-rw-r--r-- | src/yapf/yapf_rail.cpp | 10 | ||||
-rw-r--r-- | src/yapf/yapf_road.cpp | 8 | ||||
-rw-r--r-- | src/yapf/yapf_ship.cpp | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/src/yapf/yapf_base.hpp b/src/yapf/yapf_base.hpp index 0d49171cd..b1cb5e993 100644 --- a/src/yapf/yapf_base.hpp +++ b/src/yapf/yapf_base.hpp @@ -117,7 +117,8 @@ public: while (true) { m_num_steps++; Node *n = m_nodes.GetBestOpenNode(); - if (n == NULL) break; + if (n == NULL) + break; // if the best open node was worse than the best path found, we can finish if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate()) @@ -160,9 +161,9 @@ public: /** If path was found return the best node that has reached the destination. Otherwise * return the best visited node (which was nearest to the destination). */ - FORCEINLINE Node& GetBestNode() + FORCEINLINE Node* GetBestNode() { - return (m_pBestDestNode != NULL) ? *m_pBestDestNode : *m_pBestIntermediateNode; + return (m_pBestDestNode != NULL) ? m_pBestDestNode : m_pBestIntermediateNode; } /** Calls NodeList::CreateNewNode() - allocates new node that can be filled and used diff --git a/src/yapf/yapf_rail.cpp b/src/yapf/yapf_rail.cpp index 7e7713f48..91fca8194 100644 --- a/src/yapf/yapf_rail.cpp +++ b/src/yapf/yapf_rail.cpp @@ -61,11 +61,11 @@ public: // some path found // get found depot tile - Node& n = Yapf().GetBestNode(); - *depot_tile = n.GetLastTile(); + Node *n = Yapf().GetBestNode(); + *depot_tile = n->GetLastTile(); // walk through the path back to the origin - Node* pNode = &n; + Node *pNode = n; while (pNode->m_parent != NULL) { pNode = pNode->m_parent; } @@ -128,7 +128,7 @@ public: // if path not found - return INVALID_TRACKDIR Trackdir next_trackdir = INVALID_TRACKDIR; - Node* pNode = &Yapf().GetBestNode(); + Node *pNode = Yapf().GetBestNode(); if (pNode != NULL) { // path was found or at least suggested // walk through the path back to the origin @@ -165,7 +165,7 @@ public: // path was found // walk through the path back to the origin - Node* pNode = &Yapf().GetBestNode(); + Node *pNode = Yapf().GetBestNode(); while (pNode->m_parent != NULL) { pNode = pNode->m_parent; } diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp index c22683c25..ba7934c99 100644 --- a/src/yapf/yapf_road.cpp +++ b/src/yapf/yapf_road.cpp @@ -287,7 +287,7 @@ public: // if path not found - return INVALID_TRACKDIR Trackdir next_trackdir = INVALID_TRACKDIR; - Node* pNode = &Yapf().GetBestNode(); + Node *pNode = Yapf().GetBestNode(); if (pNode != NULL) { // path was found or at least suggested // walk through the path back to its origin @@ -329,7 +329,7 @@ public: // if path not found - return distance = UINT_MAX uint dist = UINT_MAX; - Node* pNode = &Yapf().GetBestNode(); + Node *pNode = Yapf().GetBestNode(); if (pNode != NULL) { // path was found or at least suggested // get the path cost estimate @@ -371,8 +371,8 @@ public: // some path found // get found depot tile - Node& n = Yapf().GetBestNode(); - TileIndex depot_tile = n.m_segment_last_tile; + Node *n = Yapf().GetBestNode(); + TileIndex depot_tile = n->m_segment_last_tile; assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD)); Depot* ret = GetDepotByTile(depot_tile); return ret; diff --git a/src/yapf/yapf_ship.cpp b/src/yapf/yapf_ship.cpp index 94c0016f3..b612bcf67 100644 --- a/src/yapf/yapf_ship.cpp +++ b/src/yapf/yapf_ship.cpp @@ -67,7 +67,7 @@ public: if (bFound) { // path was found // walk through the path back to the origin - Node* pNode = &pf.GetBestNode(); + Node* pNode = pf.GetBestNode(); Node* pPrevNode = NULL; while (pNode->m_parent != NULL) { pPrevNode = pNode; |