From 1ad8451ae2537ed8418456151c88324c898ebbc7 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sat, 2 May 2020 00:06:34 +0200 Subject: [PATCH] Core/Objects: use the static vmap check in MovePositionToFirstCollision for all path results to avoid falling below wmo surfaces when the mmap path returns unreliable data # Conflicts: # src/server/game/Entities/Object/Object.cpp --- src/server/game/Entities/Object/Object.cpp | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 65084def20..6cf70a65b0 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2565,27 +2565,25 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float // Object is using a shortcut. Check static LOS float halfHeight = GetCollisionHeight() * 0.5f; - if (path.GetPathType() & PATHFIND_SHORTCUT) + + uint32 terrainMapId = PhasingHandler::GetTerrainMapId(GetPhaseShift(), GetMap(), pos.m_positionX, pos.m_positionY); + bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(terrainMapId, + pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, + destx, desty, destz + halfHeight, + destx, desty, destz, -0.5f); + + destz -= halfHeight; + + // Collided with static LOS object, move back to collision point + if (col) { - uint32 terrainMapId = PhasingHandler::GetTerrainMapId(GetPhaseShift(), GetMap(), pos.m_positionX, pos.m_positionY); - bool col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(terrainMapId, - pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, - destx, desty, destz + halfHeight, - destx, desty, destz, -0.5f); - - destz -= halfHeight; - - // Collided with static LOS object, move back to collision point - if (col) - { - destx -= CONTACT_DISTANCE * std::cos(angle); - desty -= CONTACT_DISTANCE * std::sin(angle); - dist = std::sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty)); - } + destx -= CONTACT_DISTANCE * std::cos(angle); + desty -= CONTACT_DISTANCE * std::sin(angle); + dist = std::sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty)); } // check dynamic collision - bool col = GetMap()->getObjectHitPos(GetPhaseShift(), + col = GetMap()->getObjectHitPos(GetPhaseShift(), pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, destx, desty, destz + halfHeight, destx, desty, destz, -0.5f);