From d699d0973b6854a861b8d43e12d33dfb3f6f919a Mon Sep 17 00:00:00 2001 From: mns Date: Tue, 25 Jan 2011 01:15:37 +0300 Subject: [PATCH] [11068] Prevent infinity creature fall at fail get heght. Also fix wrong use INVALID_HEIGHT as height value. It must be used only for _check_ height, and DON'T must use as real height value. Must fix some wrong height check results. Signed-off-by: VladimirMangos --- src/game/Creature.cpp | 3 ++- src/game/GridMap.cpp | 10 +++++----- src/game/GridMap.h | 1 + src/shared/revision_nr.h | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index d37e57531..828d258de 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -1464,10 +1464,11 @@ bool Creature::FallGround() // use larger distance for vmap height search than in most other cases float tz = GetTerrain()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), true, MAX_FALL_DISTANCE); - if (tz < INVALID_HEIGHT) + if (tz <= INVALID_HEIGHT) { DEBUG_LOG("FallGround: creature %u at map %u (x: %f, y: %f, z: %f), not able to retrive a proper GetHeight (z: %f).", GetEntry(), GetMap()->GetId(), GetPositionX(), GetPositionX(), GetPositionZ(), tz); + return false; } // Abort too if the ground is very near diff --git a/src/game/GridMap.cpp b/src/game/GridMap.cpp index b8869de71..c65057177 100644 --- a/src/game/GridMap.cpp +++ b/src/game/GridMap.cpp @@ -44,7 +44,7 @@ GridMap::GridMap() m_area_map = NULL; // Height level data - m_gridHeight = INVALID_HEIGHT; + m_gridHeight = INVALID_HEIGHT_VALUE; m_gridGetHeight = &GridMap::getHeightFromFlat; m_V9 = NULL; m_V8 = NULL; @@ -55,7 +55,7 @@ GridMap::GridMap() m_liquid_offY = 0; m_liquid_width = 0; m_liquid_height = 0; - m_liquidLevel = INVALID_HEIGHT; + m_liquidLevel = INVALID_HEIGHT_VALUE; m_liquid_type = NULL; m_liquid_map = NULL; } @@ -478,10 +478,10 @@ float GridMap::getLiquidLevel(float x, float y) int cy_int = ((int)y & (MAP_RESOLUTION-1)) - m_liquid_offX; if (cx_int < 0 || cx_int >=m_liquid_height) - return INVALID_HEIGHT; + return INVALID_HEIGHT_VALUE; if (cy_int < 0 || cy_int >=m_liquid_width ) - return INVALID_HEIGHT; + return INVALID_HEIGHT_VALUE; return m_liquid_map[cx_int*m_liquid_width + cy_int]; } @@ -930,7 +930,7 @@ GridMapLiquidStatus TerrainInfo::getLiquidStatus(float x, float y, float z, uint { GridMapLiquidStatus result = LIQUID_MAP_NO_WATER; VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); - float liquid_level, ground_level = INVALID_HEIGHT; + float liquid_level, ground_level = INVALID_HEIGHT_VALUE; uint32 liquid_type; if (vmgr->GetLiquidLevel(GetMapId(), x, y, z, ReqLiquidType, liquid_level, ground_level, liquid_type)) { diff --git a/src/game/GridMap.h b/src/game/GridMap.h index 1dfeebcca..da58f2d17 100644 --- a/src/game/GridMap.h +++ b/src/game/GridMap.h @@ -203,6 +203,7 @@ typedef ACE_Atomic_Op AtomicLong; #define MAX_HEIGHT 100000.0f // can be use for find ground height at surface #define INVALID_HEIGHT -100000.0f // for check, must be equal to VMAP_INVALID_HEIGHT, real value for unknown height is VMAP_INVALID_HEIGHT_VALUE +#define INVALID_HEIGHT_VALUE -200000.0f // for return, must be equal to VMAP_INVALID_HEIGHT_VALUE, check value for unknown height is VMAP_INVALID_HEIGHT #define MAX_FALL_DISTANCE 250000.0f // "unlimited fall" to find VMap ground if it is available, just larger than MAX_HEIGHT - INVALID_HEIGHT #define DEFAULT_HEIGHT_SEARCH 10.0f // default search distance to find height at nearby locations #define DEFAULT_WATER_SEARCH 50.0f // default search distance to case detection water level diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ce9a19110..4e28d3ff5 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11067" + #define REVISION_NR "11068" #endif // __REVISION_NR_H__