From 6a08c9cbdbe43b9e9b4680e8bc835af921b5cbc4 Mon Sep 17 00:00:00 2001 From: WORISX <97387012+WORISX@users.noreply.github.com> Date: Sat, 29 Jan 2022 02:38:34 +0100 Subject: [PATCH] fix(Core/Pathfinding): Remove unnecesary LiquidData Z check (#10251) * Core/Pathfinding: Remove unnecesary LiquidData Z check *Remove an unnecessary LiquidData status check for Z correcing points count added probably for SunwellCore before the Movement Rewritte done last year , this fixes global pathfinding problems on all Movement Generators including all pathfinding problems that make creatures and players go through textures. * Update PathGenerator.cpp Typo on last commit --- .../MovementGenerators/PathGenerator.cpp | 39 ++----------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp index 620282f98..a727aafb7 100644 --- a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp @@ -576,46 +576,13 @@ void PathGenerator::BuildPointPath(const float* startPoint, const float* endPoin } _pathPoints.resize(pointCount); - uint32 newPointCount = 0; - for (uint32 i = 0; i < pointCount; ++i) { - G3D::Vector3 vector = G3D::Vector3(pathPoints[i * VERTEX_SIZE + 2], pathPoints[i * VERTEX_SIZE], pathPoints[i * VERTEX_SIZE + 1]); - LiquidData const& liquidData = _source->GetMap()->GetLiquidData(_source->GetPhaseMask(), vector.x, vector.y, vector.z, _source->GetCollisionHeight(), MAP_ALL_LIQUIDS); - // One of the points is not in the water - if (liquidData.Status == LIQUID_MAP_UNDER_WATER) - { - // if the first point is under water - // then set a proper z for it - if (i == 0) - { - vector.z = std::fmaxf(vector.z, _source->GetPositionZ()); - _pathPoints[newPointCount] = vector; - } - // if the last point is under water - // then set the desired end position instead - else if (i == pointCount - 1) - { - _pathPoints[newPointCount] = GetActualEndPosition(); - } - // if one of the mid-points of the path is underwater - // then we can create a shortcut between the previous one - // and the next one by not including it inside the list - else - continue; - } - else - { - _pathPoints[newPointCount] = vector; - } - - newPointCount++; - } - - _pathPoints.resize(newPointCount); + for (uint32 i = 0; i < pointCount; ++i) + _pathPoints[i] = G3D::Vector3(pathPoints[i * VERTEX_SIZE + 2], pathPoints[i * VERTEX_SIZE], pathPoints[i * VERTEX_SIZE + 1]); NormalizePath(); // first point is always our current location - we need the next one - SetActualEndPosition(_pathPoints[newPointCount - 1]); + SetActualEndPosition(_pathPoints[pointCount - 1]); // force the given destination, if needed if (_forceDestination &&