aboutsummaryrefslogtreecommitdiff
path: root/dep
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2019-02-06 19:32:31 +0100
committerShauren <shauren.trinity@gmail.com>2021-11-23 22:28:28 +0100
commit23489568db3cbb32f1be8c88fb02fab316fd1b28 (patch)
treefda9c04d3ca8add194e1f6d7b12fbd8995b2833c /dep
parentcefd1f94d71c67d7c74e50c0ae1a8ed873ddc9bd (diff)
Core/MMaps: Fix infinite loop in Detour
Fix an infinite loop in Detour happening in Dalaran Sewers. This is more of an emergency patch until we figure out why dtNodes have a circular reference (A -> B -> C -> A) happening quite often in this place (cherry picked from commit c8ec2dd95d07e3eec00027cdb9605529a49d6475)
Diffstat (limited to 'dep')
-rw-r--r--dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
index 4e69fcbcc53..8af14858f51 100644
--- a/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
+++ b/dep/recastnavigation/Detour/Source/DetourNavMeshQuery.cpp
@@ -26,6 +26,7 @@
#include "DetourAlloc.h"
#include "DetourAssert.h"
#include <new>
+#include <unordered_set>
/// @class dtQueryFilter
///
@@ -1206,10 +1207,16 @@ 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)
+ return DT_FAILURE;
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.