diff options
author | Ovahlord <dreadkiller@gmx.de> | 2024-01-02 19:46:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-02 19:46:44 +0100 |
commit | 97af0c31af13de23eabe4eb22ed3e71dd5602531 (patch) | |
tree | 0c816747f6b2e627b214a1adac4ebcbd5803b556 /src/server/game | |
parent | bfb9fd8a2c777651c99568ba9c6a2d4a3a468955 (diff) |
Core/Maps: implement LIQUID_MAP_OCEAN_FLOOR to identify units that are on the bottom of a liquid (#29545)
Diffstat (limited to 'src/server/game')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 | ||||
-rw-r--r-- | src/server/game/Maps/GridMap.cpp | 22 | ||||
-rw-r--r-- | src/server/game/Maps/TerrainMgr.cpp | 38 |
4 files changed, 47 insertions, 19 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 31d30c9949b..368926acc5e 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3110,6 +3110,11 @@ bool Unit::IsUnderWater() const return GetLiquidStatus() & LIQUID_MAP_UNDER_WATER; } +bool Unit::IsOnOceanFloor() const +{ + return GetLiquidStatus() & LIQUID_MAP_OCEAN_FLOOR; +} + void Unit::ProcessPositionDataChanged(PositionFullTerrainStatus const& data) { ZLiquidStatus oldLiquidStatus = GetLiquidStatus(); diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index a07883dc296..08beac15956 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1191,6 +1191,7 @@ class TC_GAME_API Unit : public WorldObject bool IsInWater() const; bool IsUnderWater() const; + bool IsOnOceanFloor() const; bool isInAccessiblePlaceFor(Creature const* c) const; void SendHealSpellLog(HealInfo& healInfo, bool critical = false); diff --git a/src/server/game/Maps/GridMap.cpp b/src/server/game/Maps/GridMap.cpp index 2d06aa25687..0d5f2587675 100644 --- a/src/server/game/Maps/GridMap.cpp +++ b/src/server/game/Maps/GridMap.cpp @@ -677,12 +677,18 @@ ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, Optional<map_l // For speed check as int values float delta = liquid_level - z; - if (delta > collisionHeight) // Under water - return LIQUID_MAP_UNDER_WATER; - if (delta > 0.0f) // In water - return LIQUID_MAP_IN_WATER; - if (delta > -0.1f) // Walk on water - return LIQUID_MAP_WATER_WALK; - // Above water - return LIQUID_MAP_ABOVE_WATER; + uint32 status = LIQUID_MAP_ABOVE_WATER; // Above water + + if (delta > collisionHeight) // Under water + status = LIQUID_MAP_UNDER_WATER; + else if (delta > 0.0f) // In water + status = LIQUID_MAP_IN_WATER; + else if (delta > -0.1f) // Walk on water + status = LIQUID_MAP_WATER_WALK; + + if (status != LIQUID_MAP_ABOVE_WATER) + if (std::fabs(ground_level - z) <= GROUND_HEIGHT_TOLERANCE) + status |= LIQUID_MAP_OCEAN_FLOOR; + + return static_cast<ZLiquidStatus>(status); } diff --git a/src/server/game/Maps/TerrainMgr.cpp b/src/server/game/Maps/TerrainMgr.cpp index 4e9a0c65e92..cfdf78021d7 100644 --- a/src/server/game/Maps/TerrainMgr.cpp +++ b/src/server/game/Maps/TerrainMgr.cpp @@ -442,14 +442,19 @@ void TerrainInfo::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, data.liquidInfo->type_flags = map_liquidHeaderTypeFlags(1 << liquidFlagType); float delta = wmoData->liquidInfo->level - z; + uint32 status = LIQUID_MAP_ABOVE_WATER; if (delta > collisionHeight) - data.liquidStatus = LIQUID_MAP_UNDER_WATER; + status = LIQUID_MAP_UNDER_WATER; else if (delta > 0.0f) - data.liquidStatus = LIQUID_MAP_IN_WATER; + status = LIQUID_MAP_IN_WATER; else if (delta > -0.1f) - data.liquidStatus = LIQUID_MAP_WATER_WALK; - else - data.liquidStatus = LIQUID_MAP_ABOVE_WATER; + status = LIQUID_MAP_WATER_WALK; + + if (status != LIQUID_MAP_ABOVE_WATER) + if (std::fabs(wmoData->floorZ - z) <= GROUND_HEIGHT_TOLERANCE) + status |= LIQUID_MAP_OCEAN_FLOOR; + + data.liquidStatus = static_cast<ZLiquidStatus>(status); } // look up liquid data from grid map if (gmap && useGridLiquid) @@ -524,12 +529,23 @@ ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, uint32 float delta = liquid_level - z; // Get position delta - if (delta > collisionHeight) // Under water - return LIQUID_MAP_UNDER_WATER; - if (delta > 0.0f) // In water - return LIQUID_MAP_IN_WATER; - if (delta > -0.1f) // Walk on water - return LIQUID_MAP_WATER_WALK; + uint32 status = LIQUID_MAP_ABOVE_WATER; + if (delta > collisionHeight) // Under water + status = LIQUID_MAP_UNDER_WATER; + else if (delta > 0.0f) // In water + status = LIQUID_MAP_IN_WATER; + else if (delta > -0.1f) // Walk on water + status = LIQUID_MAP_WATER_WALK; + + if (status != LIQUID_MAP_ABOVE_WATER) + { + if (status != LIQUID_MAP_ABOVE_WATER) + if (std::fabs(ground_level - z) <= GROUND_HEIGHT_TOLERANCE) + status |= LIQUID_MAP_OCEAN_FLOOR; + + return static_cast<ZLiquidStatus>(status); + } + result = LIQUID_MAP_ABOVE_WATER; } } |