src/yapf/yapf_ship.cpp
branchnoai
changeset 9601 b499fdd106d5
parent 6458 5cd016e1f018
child 9624 b71483f2330f
child 9912 1ac8aac92385
equal deleted inserted replaced
9600:59cc173953ae 9601:b499fdd106d5
    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 			}