From 13b10e5d20a21d40887071d7e624464f9c7f6dca Mon Sep 17 00:00:00 2001 From: bash Date: Sat, 30 May 2026 21:28:48 +0200 Subject: [PATCH] refactor(Core/Movement): Align MoveFarTo preamble + drop spline-plan throttle --- src/Ai/Base/Actions/MovementActions.cpp | 5 ++- src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp | 34 +++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Ai/Base/Actions/MovementActions.cpp b/src/Ai/Base/Actions/MovementActions.cpp index ddc3723d1..8ca2eb101 100644 --- a/src/Ai/Base/Actions/MovementActions.cpp +++ b/src/Ai/Base/Actions/MovementActions.cpp @@ -3146,9 +3146,8 @@ bool MovementAction::LaunchWalkSpline(TravelPlan& state) G3D::Vector3 const& last = state.walkPoints.back(); - // Update LastMovement so MoveFarTo's spline-active early-out - // knows about this in-flight walk and won't recompute the path - // mid-spline. Mirror what MoveTo does after dispatching a spline. + // Mirror what MoveTo does after dispatching a spline so the + // lastPath cache below picks up the in-flight waypoint chain. { float delay = static_cast(state.expectedDuration); delay = std::min(delay, static_cast(sPlayerbotAIConfig.maxWaitForMove)); diff --git a/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp b/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp index 88fbcfab4..a0bb43efd 100644 --- a/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp +++ b/src/Ai/World/Rpg/Action/NewRpgBaseAction.cpp @@ -48,7 +48,19 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest) { if (dest == WorldPosition()) + { + EmitDebugMove("MoveFar", "empty-dest", 0.0f, 0.0f, 0.0f); return false; + } + + UpdateMovementState(); + + if (!IsMovingAllowed()) + { + EmitDebugMove("MoveFar", "cant-move", + dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ()); + return false; + } // Already-at-dest short-stop. Below targetPosRecalcDistance the // move is effectively done — stop any active spline and clear @@ -64,26 +76,12 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest) lastMove.clear(); } bot->StopMoving(); + EmitDebugMove("MoveFar", "arrived", + dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ()); return false; } } - // Let an in-flight spline finish before recomputing — prevents - // oscillation when re-resolve produces a slightly different endpoint. - { - LastMovement& lastMove = AI_VALUE(LastMovement&, "last movement"); - if (bot->isMoving() && lastMove.lastMoveToMapId == bot->GetMapId()) - { - float remaining = bot->GetExactDist(lastMove.lastMoveToX, lastMove.lastMoveToY, lastMove.lastMoveToZ); - if (remaining > 10.0f) - { - EmitDebugMove("MoveFar", "spline-plan", - lastMove.lastMoveToX, lastMove.lastMoveToY, lastMove.lastMoveToZ); - return true; - } - } - } - // 10% lastPath reuse — if the cached path's endpoint is still // close (within 10%) to the new dest, trim the cached path to // the bot's current position via makeShortCut and re-dispatch. @@ -240,7 +238,11 @@ bool NewRpgBaseAction::MoveFarTo(WorldPosition dest) // the bot's STEEP/water filter is honored via CreateFilter. If even // that fails, the engine falls back to a direct spline. if (bot->GetMapId() != dest.GetMapId()) + { + EmitDebugMove("MoveFar", "cross-map", + dest.GetPositionX(), dest.GetPositionY(), dest.GetPositionZ()); return false; + } char const* reason = (probe.empty() || probe.size() < 2) ? "mmap-empty" : "mmap-noprogress"; EmitDebugMove("MoveFar", reason,