diff options
| author | Jeremy <Golrag@users.noreply.github.com> | 2018-02-16 20:59:19 +0100 |
|---|---|---|
| committer | jackpoz <giacomopoz@gmail.com> | 2018-02-16 20:59:19 +0100 |
| commit | 9e0faace9a5114fc2324c2c601ba943272e0d6ff (patch) | |
| tree | ee7cb56b687598c96d5e967d8f8857fc5cee8b07 /src/server/game/Maps/Map.cpp | |
| parent | 8aa10f6c65ba7fc8363a663b305fede95d0ccb58 (diff) | |
Core/Entities: Reduce the probability of units dropping under the map (#21322)
Reduce the probabilty of going under the map
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
| -rw-r--r-- | src/server/game/Maps/Map.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 6958392f66d..8a55e13da77 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2377,12 +2377,12 @@ inline GridMap* Map::GetGrid(float x, float y) return GridMaps[gx][gy]; } -float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/) const +float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const { if (const_cast<Map*>(this)->GetGrid(x, y)) { // we need ground level (including grid height version) for proper return water level in point - float ground_z = GetHeight(phasemask, x, y, z + collisionHeight, true, 50.0f); + float ground_z = GetHeight(phasemask, x, y, z, true, maxSearchDist, collisionHeight); if (ground) *ground = ground_z; @@ -2403,30 +2403,22 @@ float Map::GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, fl return VMAP_INVALID_HEIGHT_VALUE; } -float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const +float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/, float collisionHeight) const { // find raw .map surface under Z coordinates - float mapHeight = VMAP_INVALID_HEIGHT_VALUE; - if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) - { - float gridHeight = gmap->getHeight(x, y); - if (z > gridHeight) - mapHeight = gridHeight; - } + float const gridHeight = GetGridMapHeight(x, y); + float mapHeight = z + collisionHeight > gridHeight ? gridHeight : VMAP_INVALID_HEIGHT_VALUE; float vmapHeight = VMAP_INVALID_HEIGHT_VALUE; if (checkVMap) - { - VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); - if (vmgr->isHeightCalcEnabled()) - vmapHeight = vmgr->getHeight(GetId(), x, y, z, maxSearchDist); - } + vmapHeight = GetVMapFloor(x, y, z, maxSearchDist, collisionHeight); - // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT - // vmapheight set for any under Z value or <= INVALID_HEIGHT - if (vmapHeight > INVALID_HEIGHT) + bool const hasVmapFloor = vmapHeight > INVALID_HEIGHT; + bool const hasMapFloor = mapHeight > INVALID_HEIGHT; + + if (hasVmapFloor) { - if (mapHeight > INVALID_HEIGHT) + if (hasMapFloor) { // we have mapheight and vmapheight and must select more appropriate @@ -2441,7 +2433,7 @@ float Map::GetHeight(float x, float y, float z, bool checkVMap /*= true*/, float return vmapHeight; // we have only vmapHeight (if have) } - return mapHeight; // explicitly use map data + return gridHeight; // explicitly use map data } float Map::GetMinHeight(float x, float y) const @@ -2452,6 +2444,19 @@ float Map::GetMinHeight(float x, float y) const return -500.0f; } +float Map::GetGridMapHeight(float x, float y) const +{ + if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y)) + return gmap->getHeight(x, y); + + return VMAP_INVALID_HEIGHT_VALUE; +} + +float Map::GetVMapFloor(float x, float y, float z, float maxSearchDist, float collisionHeight) const +{ + return VMAP::VMapFactory::createOrGetVMapManager()->getHeight(GetId(), x, y, z + collisionHeight, maxSearchDist); +} + inline bool IsOutdoorWMO(uint32 mogpFlags, int32 /*adtId*/, int32 /*rootId*/, int32 /*groupId*/, WMOAreaTableEntry const* wmoEntry, AreaTableEntry const* atEntry) { bool outdoor = true; @@ -2771,6 +2776,11 @@ float Map::GetWaterLevel(float x, float y) const return 0; } +float Map::GetCeil(float x, float y, float z, float maxSearchDist, float collisionHeight) const +{ + return VMAP::VMapFactory::createOrGetVMapManager()->getCeil(GetId(), x, y, z + collisionHeight, maxSearchDist); +} + bool Map::isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const { if ((checks & LINEOFSIGHT_CHECK_VMAP) |
