src/yapf/yapf_ship.cpp
branchcpp_gui
changeset 6308 646711c5feaa
parent 6268 4b5241e5dd10
equal deleted inserted replaced
6307:f40e88cff863 6308:646711c5feaa
    59 		Tpf pf;
    59 		Tpf pf;
    60 		// set origin and destination nodes
    60 		// set origin and destination nodes
    61 		pf.SetOrigin(src_tile, trackdirs);
    61 		pf.SetOrigin(src_tile, trackdirs);
    62 		pf.SetDestination(v->dest_tile, dest_trackdirs);
    62 		pf.SetDestination(v->dest_tile, dest_trackdirs);
    63 		// find best path
    63 		// find best path
    64 		bool bFound = pf.FindPath(v);
    64 		pf.FindPath(v);
    65 
    65 
    66 		Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found"
    66 		Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found"
    67 		if (bFound) {
    67 
    68 			// path was found
    68 		Node* pNode = pf.GetBestNode();
       
    69 		if (pNode != NULL) {
    69 			// walk through the path back to the origin
    70 			// walk through the path back to the origin
    70 			Node* pNode = &pf.GetBestNode();
       
    71 			Node* pPrevNode = NULL;
    71 			Node* pPrevNode = NULL;
    72 			while (pNode->m_parent != NULL) {
    72 			while (pNode->m_parent != NULL) {
    73 				pPrevNode = pNode;
    73 				pPrevNode = pNode;
    74 				pNode = pNode->m_parent;
    74 				pNode = pNode->m_parent;
    75 			}
    75 			}