src/yapf/yapf_road.cpp
branchcpp_gui
changeset 6308 646711c5feaa
parent 6268 4b5241e5dd10
equal deleted inserted replaced
6307:f40e88cff863 6308:646711c5feaa
   285 		// find the best path
   285 		// find the best path
   286 		Yapf().FindPath(v);
   286 		Yapf().FindPath(v);
   287 
   287 
   288 		// if path not found - return INVALID_TRACKDIR
   288 		// if path not found - return INVALID_TRACKDIR
   289 		Trackdir next_trackdir = INVALID_TRACKDIR;
   289 		Trackdir next_trackdir = INVALID_TRACKDIR;
   290 		Node* pNode = &Yapf().GetBestNode();
   290 		Node *pNode = Yapf().GetBestNode();
   291 		if (pNode != NULL) {
   291 		if (pNode != NULL) {
   292 			// path was found or at least suggested
   292 			// path was found or at least suggested
   293 			// walk through the path back to its origin
   293 			// walk through the path back to its origin
   294 			while (pNode->m_parent != NULL) {
   294 			while (pNode->m_parent != NULL) {
   295 				pNode = pNode->m_parent;
   295 				pNode = pNode->m_parent;
   327 		// find the best path
   327 		// find the best path
   328 		Yapf().FindPath(v);
   328 		Yapf().FindPath(v);
   329 
   329 
   330 		// if path not found - return distance = UINT_MAX
   330 		// if path not found - return distance = UINT_MAX
   331 		uint dist = UINT_MAX;
   331 		uint dist = UINT_MAX;
   332 		Node* pNode = &Yapf().GetBestNode();
   332 		Node *pNode = Yapf().GetBestNode();
   333 		if (pNode != NULL) {
   333 		if (pNode != NULL) {
   334 			// path was found or at least suggested
   334 			// path was found or at least suggested
   335 			// get the path cost estimate
   335 			// get the path cost estimate
   336 			dist = pNode->GetCostEstimate();
   336 			dist = pNode->GetCostEstimate();
   337 		}
   337 		}
   369 		bool bFound = Yapf().FindPath(v);
   369 		bool bFound = Yapf().FindPath(v);
   370 		if (!bFound) return false;
   370 		if (!bFound) return false;
   371 
   371 
   372 		// some path found
   372 		// some path found
   373 		// get found depot tile
   373 		// get found depot tile
   374 		Node& n = Yapf().GetBestNode();
   374 		Node *n = Yapf().GetBestNode();
   375 		TileIndex depot_tile = n.m_segment_last_tile;
   375 		TileIndex depot_tile = n->m_segment_last_tile;
   376 		assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD));
   376 		assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD));
   377 		Depot* ret = GetDepotByTile(depot_tile);
   377 		Depot* ret = GetDepotByTile(depot_tile);
   378 		return ret;
   378 		return ret;
   379 	}
   379 	}
   380 };
   380 };