diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/collision/Management/IVMapManager.h | 2 | ||||
-rw-r--r-- | src/server/collision/Management/VMapManager2.cpp | 4 | ||||
-rw-r--r-- | src/server/collision/Management/VMapManager2.h | 2 | ||||
-rw-r--r-- | src/server/collision/Maps/MapTree.cpp | 4 | ||||
-rw-r--r-- | src/server/collision/Maps/MapTree.h | 2 | ||||
-rw-r--r-- | src/server/collision/VMapDefinitions.h | 10 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 3 | ||||
-rw-r--r-- | src/server/game/Maps/Map.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Maps/Map.h | 4 |
9 files changed, 14 insertions, 21 deletions
diff --git a/src/server/collision/Management/IVMapManager.h b/src/server/collision/Management/IVMapManager.h index 6a0e7179fa7..59262d14379 100644 --- a/src/server/collision/Management/IVMapManager.h +++ b/src/server/collision/Management/IVMapManager.h @@ -61,7 +61,7 @@ namespace VMAP virtual void unloadMap(unsigned int pMapId) = 0; virtual bool isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2) = 0; - virtual float getHeight(unsigned int pMapId, float x, float y, float z) = 0; + virtual float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist) = 0; /** test if we hit an object. return true if we hit one. rx,ry,rz will hold the hit position or the dest position, if no intersection was found return a position, that is pReduceDist closer to the origin diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp index 61b202c9342..4f009fabeb1 100644 --- a/src/server/collision/Management/VMapManager2.cpp +++ b/src/server/collision/Management/VMapManager2.cpp @@ -235,7 +235,7 @@ namespace VMAP get height or INVALID_HEIGHT if no height available */ - float VMapManager2::getHeight(unsigned int pMapId, float x, float y, float z) + float VMapManager2::getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist) { float height = VMAP_INVALID_HEIGHT_VALUE; //no height if (isHeightCalcEnabled()) @@ -244,7 +244,7 @@ namespace VMAP if (instanceTree != iInstanceMapTrees.end()) { Vector3 pos = convertPositionToInternalRep(x,y,z); - height = instanceTree->second->getHeight(pos); + height = instanceTree->second->getHeight(pos, maxSearchDist); if (!(height < G3D::inf())) { height = VMAP_INVALID_HEIGHT_VALUE; //no height diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h index 953a8f11fa7..920c9993cf5 100644 --- a/src/server/collision/Management/VMapManager2.h +++ b/src/server/collision/Management/VMapManager2.h @@ -92,7 +92,7 @@ namespace VMAP fill the hit pos and return true, if an object was hit */ bool getObjectHitPos(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float pModifyDist); - float getHeight(unsigned int pMapId, float x, float y, float z); + float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist); bool processCommand(char *pCommand) { return false; } // for debug and extensions diff --git a/src/server/collision/Maps/MapTree.cpp b/src/server/collision/Maps/MapTree.cpp index b47e34b2b72..4fce91920e9 100644 --- a/src/server/collision/Maps/MapTree.cpp +++ b/src/server/collision/Maps/MapTree.cpp @@ -224,12 +224,12 @@ namespace VMAP //========================================================= - float StaticMapTree::getHeight(const Vector3& pPos) const + float StaticMapTree::getHeight(const Vector3& pPos, float maxSearchDist) const { float height = G3D::inf(); Vector3 dir = Vector3(0,0,-1); G3D::Ray ray(pPos, dir); // direction with length of 1 - float maxDist = VMapDefinitions::getMaxCanFallDistance(); + float maxDist = maxSearchDist; if (getIntersectionTime(ray, maxDist, false)) { height = pPos.z - maxDist; diff --git a/src/server/collision/Maps/MapTree.h b/src/server/collision/Maps/MapTree.h index 8f2242da5a6..a9ca3509b90 100644 --- a/src/server/collision/Maps/MapTree.h +++ b/src/server/collision/Maps/MapTree.h @@ -70,7 +70,7 @@ namespace VMAP bool isInLineOfSight(const G3D::Vector3& pos1, const G3D::Vector3& pos2) const; bool getObjectHitPos(const G3D::Vector3& pos1, const G3D::Vector3& pos2, G3D::Vector3& pResultHitPos, float pModifyDist) const; - float getHeight(const G3D::Vector3& pPos) const; + float getHeight(const G3D::Vector3& pPos, float maxSearchDist) const; bool getAreaInfo(G3D::Vector3 &pos, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const; bool GetLocationInfo(const Vector3 &pos, LocationInfo &info) const; diff --git a/src/server/collision/VMapDefinitions.h b/src/server/collision/VMapDefinitions.h index 5f4a976ed2a..51980059566 100644 --- a/src/server/collision/VMapDefinitions.h +++ b/src/server/collision/VMapDefinitions.h @@ -24,18 +24,8 @@ namespace VMAP { - //===================================== - #define MAX_CAN_FALL_DISTANCE 10.0f const char VMAP_MAGIC[] = "VMAP_3.0"; - class VMapDefinitions - { - public: - static float getMaxCanFallDistance() { return MAX_CAN_FALL_DISTANCE; } - }; - - //====================================== - // defined in TileAssembler.cpp currently... bool readChunk(FILE *rf, char *dest, const char *compare, uint32 len); } diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index 9278c6c323b..c4a503ef57c 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -1540,7 +1540,8 @@ bool Creature::FallGround() float x, y, z; GetPosition(x, y, z); - float ground_Z = GetMap()->GetHeight(x, y, z); + // use larger distance for vmap height search than in most other cases + float ground_Z = GetMap()->GetHeight(x, y, z, true, MAX_FALL_DISTANCE); if (fabs(ground_Z - z) < 0.1f) return false; diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 6c9b505d6c9..8ae9c969b60 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -1680,7 +1680,7 @@ inline GridMap *Map::GetGrid(float x, float y) return GridMaps[gx][gy]; } -float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const +float Map::GetHeight(float x, float y, float z, bool pUseVmaps, float maxSearchDist) const { // find raw .map surface under Z coordinates float mapHeight; @@ -1704,7 +1704,7 @@ float Map::GetHeight(float x, float y, float z, bool pUseVmaps) const if (vmgr->isHeightCalcEnabled()) { // look from a bit higher pos to find the floor - vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f); + vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f, maxSearchDist); } else vmapHeight = VMAP_INVALID_HEIGHT_VALUE; diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 4d25381fbe1..94352fddc59 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -234,6 +234,8 @@ typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList; #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 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 MIN_UNLOAD_DELAY 1 // immediate unload typedef std::map<uint32/*leaderDBGUID*/, CreatureGroup*> CreatureGroupHolderType; @@ -313,7 +315,7 @@ class Map : public GridRefManager<NGridType> // some calls like isInWater should not use vmaps due to processor power // can return INVALID_HEIGHT if under z+2 z coord not found height - float GetHeight(float x, float y, float z, bool pCheckVMap=true) const; + float GetHeight(float x, float y, float z, bool pCheckVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const; ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data = 0) const; |