From fa4be652a0bc715493bd528981445a293b1e5cc1 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Sat, 23 Feb 2019 22:40:38 +0100 Subject: [PATCH] Core/Objects: added missing changes to last commit --- src/server/game/Entities/Object/Object.cpp | 43 ++++++++++------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 39b4e07806c..db68b8559ac 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -1659,33 +1659,28 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const if (Unit const* unit = ToUnit()) { - if (!unit->CanFly()) - { - bool canSwim = unit->CanSwim(); - float ground_z = z; - float max_z; - if (canSwim) - max_z = GetMapWaterOrGroundLevel(x, y, z, &ground_z); - else - max_z = ground_z = GetMapHeight(x, y, z); + // Unit is flying, ignore. + if (unit->IsFlying()) + return; - if (max_z > INVALID_HEIGHT) - { - // hovering units cannot go below their hover height - float hoverOffset = unit->GetHoverOffset(); - max_z += hoverOffset; - ground_z += hoverOffset; - - if (z > max_z) - z = max_z; - else if (z < ground_z) - z = ground_z; - } - } + bool canSwim = unit->CanSwim(); + float ground_z = z; + float max_z; + if (canSwim) + max_z = GetMapWaterOrGroundLevel(x, y, z, &ground_z); else + max_z = ground_z = GetMapHeight(x, y, z); + + if (max_z > INVALID_HEIGHT) { - float ground_z = GetMapHeight(x, y, z) + unit->GetHoverOffset(); - if (z < ground_z) + // hovering units cannot go below their hover height + float hoverOffset = unit->GetHoverOffset(); + max_z += hoverOffset; + ground_z += hoverOffset; + + if (z > max_z && !unit->CanFly()) + z = max_z; + else if (z < ground_z) z = ground_z; } }