From 5cc2b4114636c99b32cd6e7c3c5e7f1a2ea2d873 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Fri, 11 Sep 2020 20:50:57 +0200 Subject: [PATCH] Core/Movement: setting path length limits will now round the amount of smooth path points up instead of down to reduce edge cases in which charge effects close to their maximum cast range would return no path --- src/server/game/Movement/PathGenerator.cpp | 8 ++++++++ src/server/game/Movement/PathGenerator.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index d95489cb0ad..44096fa69b2 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -1031,6 +1031,14 @@ bool PathGenerator::IsInvalidDestinationZ(Unit const* target) const return (target->GetPositionZ() - GetActualEndPosition().z) > 5.0f; } +void PathGenerator::SetPathLengthLimit(float length) +{ + if (!(uint32(length) % 4)) + _pointPathLimit = std::min(length / SMOOTH_PATH_STEP_SIZE, MAX_POINT_PATH_LENGTH); + else + _pointPathLimit = std::min((length + SMOOTH_PATH_STEP_SIZE) / SMOOTH_PATH_STEP_SIZE, MAX_POINT_PATH_LENGTH); +} + void PathGenerator::AddFarFromPolyFlags(bool startFarFromPoly, bool endFarFromPoly) { if (startFarFromPoly) diff --git a/src/server/game/Movement/PathGenerator.h b/src/server/game/Movement/PathGenerator.h index b785c2739dd..8304e40499f 100644 --- a/src/server/game/Movement/PathGenerator.h +++ b/src/server/game/Movement/PathGenerator.h @@ -66,7 +66,7 @@ class TC_GAME_API PathGenerator // option setters - use optional void SetUseStraightPath(bool useStraightPath) { _useStraightPath = useStraightPath; } - void SetPathLengthLimit(float distance) { _pointPathLimit = std::min(uint32(distance/SMOOTH_PATH_STEP_SIZE), MAX_POINT_PATH_LENGTH); } + void SetPathLengthLimit(float distance); void SetUseRaycast(bool useRaycast) { _useRaycast = useRaycast; } // result getters