diff options
author | Treeston <treeston.mmoc@gmail.com> | 2017-06-08 00:25:06 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2017-06-08 00:25:06 +0200 |
commit | f6c849729b27b77228704b595de3adaf24da2c10 (patch) | |
tree | b9f7e1ae9c6db0aa367c353ebd2a3f5dddf860d1 /src/common/Collision/Management/VMapManager2.cpp | |
parent | 1660bb7d27d6f42b49012a6b57e3c2b2eab20fd3 (diff) |
[3.3.5] Get zone/area IDs from vmap data in the liquid update (#19840)
* Add new method Map::getFullVMapDataForPosition to get area info and liquid info in a single vmap lookup
* Use this lookup in Map:: relocation methods to update m_areaId and m_zoneId fields on WorldObject
* Adjust GetZoneId/GetAreaId on WorldObject to always return these cached fields
* Clean up liquid state handling on Unit and Player
* Hand floor's Z coord up through GetFullTerrainStatusForPosition, use it to update a new field in WorldObject, and use that to feed a new GetFloorZ call on WorldObject.
Closes #16489
Diffstat (limited to 'src/common/Collision/Management/VMapManager2.cpp')
-rw-r--r-- | src/common/Collision/Management/VMapManager2.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index 9981f722456..33bf7338616 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -279,6 +279,37 @@ namespace VMAP return false; } + void VMapManager2::getAreaAndLiquidData(unsigned int mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData& data) const + { + if (IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LIQUIDSTATUS)) + { + data.floorZ = z; + int32 adtId, rootId, groupId; + uint32 flags; + if (getAreaInfo(mapId, x, y, data.floorZ, flags, adtId, rootId, groupId)) + data.areaInfo = boost::in_place(adtId, rootId, groupId, flags); + return; + } + InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId); + if (instanceTree != iInstanceMapTrees.end()) + { + LocationInfo info; + Vector3 pos = convertPositionToInternalRep(x, y, z); + if (instanceTree->second->GetLocationInfo(pos, info)) + { + data.floorZ = info.ground_Z; + uint32 liquidType = info.hitModel->GetLiquidType(); + float liquidLevel; + if (!reqLiquidType || (GetLiquidFlagsPtr(liquidType) & reqLiquidType)) + if (info.hitInstance->GetLiquidLevel(pos, info, liquidLevel)) + data.liquidInfo = boost::in_place(liquidType, liquidLevel); + + if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_AREAFLAG)) + data.areaInfo = boost::in_place(info.hitInstance->adtId, info.rootId, info.hitModel->GetWmoID(), info.hitModel->GetMogpFlags()); + } + } + } + WorldModel* VMapManager2::acquireModelInstance(const std::string& basepath, const std::string& filename, uint32 flags/* Only used when creating the model */) { //! Critical section, thread safe access to iLoadedModelFiles |