# UNDF: UNDF-2026-000000963 --- a/apps/openmw/mwmechanics/pathgrid.cpp +++ b/apps/openmw/mwmechanics/pathgrid.cpp @@ -1,6 +1,7 @@ #include "pathgrid.hpp" #include +#include #include #include @@ -57,6 +58,7 @@ int mSCCId = 0; size_t mSCCIndex = 0; std::vector mSCCStack; + std::unordered_set mSCCOnStack; std::vector> mSCCPoint; // first is index, second is lowlink // v is the pathgrid point index (some call them vertices) @@ -66,6 +68,7 @@ mSCCPoint[v].second = mSCCIndex; // lowlink mSCCIndex++; mSCCStack.push_back(v); + mSCCOnStack.insert(v); size_t w; for (const auto& edge : mGraph[v].edges) @@ -77,7 +80,7 @@ mSCCPoint[v].second = std::min(mSCCPoint[v].second, mSCCPoint[w].second); } - else if (std::find(mSCCStack.begin(), mSCCStack.end(), w) != mSCCStack.end()) + else if (mSCCOnStack.count(w)) mSCCPoint[v].second = std::min(mSCCPoint[v].second, mSCCPoint[w].first); } @@ -88,6 +91,7 @@ { w = mSCCStack.back(); mSCCStack.pop_back(); + mSCCOnStack.erase(w); mGraph[w].componentId = mSCCId; } while (w != v); mSCCId++;