(svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
authorKUDr
Fri, 20 Apr 2007 19:13:35 +0000
changeset 7006 e1ff46bee5b4
parent 7005 09d7f6a8f398
child 7007 7a1476a23e56
(svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
src/yapf/yapf_base.hpp
src/yapf/yapf_rail.cpp
src/yapf/yapf_road.cpp
src/yapf/yapf_ship.cpp
--- a/src/yapf/yapf_base.hpp	Fri Apr 20 17:52:28 2007 +0000
+++ b/src/yapf/yapf_base.hpp	Fri Apr 20 19:13:35 2007 +0000
@@ -117,7 +117,8 @@
 		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 @@
 	/** 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
--- a/src/yapf/yapf_rail.cpp	Fri Apr 20 17:52:28 2007 +0000
+++ b/src/yapf/yapf_rail.cpp	Fri Apr 20 19:13:35 2007 +0000
@@ -61,11 +61,11 @@
 
 		// 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 @@
 
 		// 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 @@
 
 		// 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;
 		}
--- a/src/yapf/yapf_road.cpp	Fri Apr 20 17:52:28 2007 +0000
+++ b/src/yapf/yapf_road.cpp	Fri Apr 20 19:13:35 2007 +0000
@@ -287,7 +287,7 @@
 
 		// 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 @@
 
 		// 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 @@
 
 		// 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;
--- a/src/yapf/yapf_ship.cpp	Fri Apr 20 17:52:28 2007 +0000
+++ b/src/yapf/yapf_ship.cpp	Fri Apr 20 19:13:35 2007 +0000
@@ -67,7 +67,7 @@
 		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;