From 64385e9ed0822427bca5814d03a3f4c4d7a6db9f Mon Sep 17 00:00:00 2001 From: Jakob Botsch Nielsen Date: Wed, 27 Jul 2016 20:40:42 +0200 Subject: [PATCH] Fix findPath to return DT_OUT_OF_NODES correctly (#222) findPath was unconditionally overriding the status it used to indicate DT_OUT_OF_NODES for later. Restore this behavior so it properly can return this failure flag. Fix #221 --- Detour/Source/DetourNavMeshQuery.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Detour/Source/DetourNavMeshQuery.cpp b/Detour/Source/DetourNavMeshQuery.cpp index 7368efe..75af102 100644 --- a/Detour/Source/DetourNavMeshQuery.cpp +++ b/Detour/Source/DetourNavMeshQuery.cpp @@ -1052,7 +1052,7 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, dtNode* lastBestNode = startNode; float lastBestNodeCost = startNode->total; - dtStatus status = DT_SUCCESS; + bool outOfNodes = false; while (!m_openList->empty()) { @@ -1110,7 +1110,7 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, dtNode* neighbourNode = m_nodePool->getNode(neighbourRef, crossSide); if (!neighbourNode) { - status |= DT_OUT_OF_NODES; + outOfNodes = true; continue; } @@ -1190,10 +1190,13 @@ dtStatus dtNavMeshQuery::findPath(dtPolyRef startRef, dtPolyRef endRef, } } - status = getPathToNode(lastBestNode, path, pathCount, maxPath); + dtStatus status = getPathToNode(lastBestNode, path, pathCount, maxPath); if (lastBestNode->id != endRef) status |= DT_PARTIAL_RESULT; + + if (outOfNodes) + status |= DT_OUT_OF_NODES; return status; }