From 7e5a28b064f30da07ba7100190cf1559cd189226 Mon Sep 17 00:00:00 2001 From: killerwife Date: Tue, 28 Oct 2025 10:49:51 +0100 Subject: [PATCH] SmartAI: Fix npcs not waypointing when offset is too big (#23453) --- src/server/game/AI/SmartScripts/SmartAI.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index e799c923c..198c7adb4 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -157,15 +157,14 @@ void SmartAI::GenerateWayPointArray(Movement::PointsArray* points) pVector.push_back(G3D::Vector3(me->GetPositionX(), me->GetPositionY(), me->GetPositionZ())); uint32 wpCounter = mCurrentWPID; - auto itr = mWayPoints->find(wpCounter++); - do + uint32 length = (mWayPoints->size() - mCurrentWPID) * size; + + uint32 cnt = 0; + for (auto itr = mWayPoints->find(wpCounter); itr != mWayPoints->end() && cnt++ <= length; ++itr) { WaypointData const& wp = (*itr).second; pVector.push_back(G3D::Vector3(wp.x, wp.y, wp.z)); - - itr = mWayPoints->find(wpCounter++); } - while (itr != mWayPoints->end()); if (pVector.size() > 2) // more than source + dest {