aboutsummaryrefslogtreecommitdiff
path: root/dep/recastnavigation
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-02-08 22:21:03 +0100
committerShauren <shauren.trinity@gmail.com>2021-11-23 22:29:58 +0100
commitb0703f943ce34030d28dcdcbec0d154371fb4443 (patch)
treeb0a5c163868031438e7743b6f5509e916c0a7aaa /dep/recastnavigation
parent2682bf0fcace1eb10ead616233e67cae62065441 (diff)
Core/MMaps: Change infinite loop fix in Detour
Change the infinite loop fix in Detour to allow looping through all the m_nodePool nodes max once, otherwise it most likely means that we entered an infinite loop. This is currently set to 1024. (cherry picked from commit 12e6faa0fa0cf389bcebd4a6f2220e71c697250c)
Diffstat (limited to 'dep/recastnavigation')
-rw-r--r--dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
index 8af14858f51..864ba31411a 100644
--- a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
+++ b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
@@ -26,7 +26,6 @@
#include "DetourAlloc.h"
#include "DetourAssert.h"
#include <new>
-#include <unordered_set>
/// @class dtQueryFilter
///
@@ -1207,16 +1206,14 @@ dtStatus dtNavMeshQuery::getPathToNode(dtNode* endNode, dtPolyRef* path, int* pa
// Find the length of the entire path.
dtNode* curNode = endNode;
int length = 0;
- std::unordered_set<int> processedIds;
- bool alreadyProcessed = false;
do
{
- length++;
- alreadyProcessed = !processedIds.insert(curNode->pidx).second;
- if (alreadyProcessed)
+ // Go through the whole m_nodepool max once, otherwise it's most likely a sign of infinite loop
+ if (length > m_nodePool->getMaxNodes())
return DT_FAILURE;
- curNode = m_nodePool->getNodeAtIdx(curNode->pidx);
+ length++;
+ curNode = m_nodePool->getNodeAtIdx(curNode->pidx);
} while (curNode);
// If the path cannot be fully stored then advance to the last node we will be able to store.