From 990e2f2016168e6875b47088a8641afcadb63bd8 Mon Sep 17 00:00:00 2001 From: bash Date: Sat, 30 May 2026 23:13:32 +0200 Subject: [PATCH] refactor(Core/Movement): Drop redundant prefix-trim + setPath in DispatchPathPoints --- src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp | 40 +------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp b/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp index 693cb2bb4..d52cae8c9 100644 --- a/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp +++ b/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp @@ -158,44 +158,8 @@ bool NewRpgBaseAction::DispatchPathPoints(WorldPosition const& dest, if (points.size() < 2) return false; - // Prefix trim (cmangos parity: makeShortCut on every dispatch). - // Drop leading waypoints behind the bot's current position so the - // spline begins from where the bot actually is, not from a stale - // planner-start. Picks the waypoint closest to the bot in 3D and - // erases everything before it. - { - float const bx = bot->GetPositionX(); - float const by = bot->GetPositionY(); - float const bz = bot->GetPositionZ(); - float minSq = std::numeric_limits::max(); - size_t closest = 0; - for (size_t i = 0; i < points.size(); ++i) - { - float dx = points[i].x - bx; - float dy = points[i].y - by; - float dz = points[i].z - bz; - float sq = dx * dx + dy * dy + dz * dz; - if (sq < minSq) - { - minSq = sq; - closest = i; - } - } - if (closest > 0) - points.erase(points.begin(), points.begin() + closest); - if (points.size() < 2) - return false; - } - - // Save planner output for next-tick reuse. - { - LastMovement& lm = AI_VALUE(LastMovement&, "last movement"); - std::vector wpts; - wpts.reserve(points.size()); - for (auto const& pt : points) - wpts.emplace_back(dest.GetMapId(), pt.x, pt.y, pt.z); - lm.setPath(TravelPath(wpts)); - } + // MoveFarTo runs makeShortCut + setPath upstream now, so no need + // for the local prefix-trim or lastMove.setPath here. for (auto& pt : points) bot->UpdateAllowedPositionZ(pt.x, pt.y, pt.z);