mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 15:40:45 +01:00
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.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user