@@ -58,25 +58,25 @@ public:
// create pathfinder instance
Tpf pf;
// set origin and destination nodes
pf.SetOrigin(src_tile, trackdirs);
pf.SetDestination(v->dest_tile, dest_trackdirs);
// find best path
bool bFound = pf.FindPath(v);
Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found"
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;
pNode = pNode->m_parent;
}
// return trackdir from the best next node (direct child of origin)
Node& best_next_node = *pPrevNode;
assert(best_next_node.GetTile() == tile);
next_trackdir = best_next_node.GetTrackdir();
return next_trackdir;