Core/Maps: Fixed retrieving terrain info when on child maps

This commit is contained in:
Shauren authored and Ovahlord committed 2023-01-02 15:23:21 +01:00
1 parent f76990a37b
commit eeb2f63b65
10 files changed
+92 -99

No files matched your search

+1 -1
View File
@@ -3466,7 +3466,7 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float
// Unit is flying. Do a VMap check to avoid moving the position into walls or obstacles
if (path.GetPathType() & PATHFIND_NOT_USING_PATH)
{
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(GetPhaseShift(), GetMap()->GetTerrain(), pos.m_positionX, pos.m_positionY);
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(GetPhaseShift(), GetMapId(), GetMap()->GetTerrain(), pos.m_positionX, pos.m_positionY);
col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(terrainMapId,
pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight,
destx, desty, destz + halfHeight,
+1 -1
View File
@@ -155,7 +155,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recvData*/)
mapID = corpseMapEntry->CorpseMapID;
x = corpseMapEntry->Corpse.X;
y = corpseMapEntry->Corpse.Y;
z = entranceTerrain->GetStaticHeight(GetPlayer()->GetPhaseShift(), x, y, MAX_HEIGHT);
z = entranceTerrain->GetStaticHeight(GetPlayer()->GetPhaseShift(), mapID, x, y, MAX_HEIGHT);
}
}
}
+13 -13
View File
@@ -1504,69 +1504,69 @@ void Map::UnloadAll()
void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data,
map_liquidHeaderTypeFlags reqLiquidType, float collisionHeight)
{
m_terrain->GetFullTerrainStatusForPosition(phaseShift, x, y, z, data, reqLiquidType, collisionHeight);
m_terrain->GetFullTerrainStatusForPosition(phaseShift, GetId(), x, y, z, data, reqLiquidType, collisionHeight);
}
ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data,
float collisionHeight)
{
return m_terrain->GetLiquidStatus(phaseShift, x, y, z, ReqLiquidType, data, collisionHeight);
return m_terrain->GetLiquidStatus(phaseShift, GetId(), x, y, z, ReqLiquidType, data, collisionHeight);
}
uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z)
{
return m_terrain->GetAreaId(phaseShift, x, y, z);
return m_terrain->GetAreaId(phaseShift, GetId(), x, y, z);
}
uint32 Map::GetZoneId(PhaseShift const& phaseShift, float x, float y, float z)
{
return m_terrain->GetZoneId(phaseShift, x, y, z);
return m_terrain->GetZoneId(phaseShift, GetId(), x, y, z);
}
void Map::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, float x, float y, float z)
{
return m_terrain->GetZoneAndAreaId(phaseShift, zoneid, areaid, x, y, z);
return m_terrain->GetZoneAndAreaId(phaseShift, GetId(), zoneid, areaid, x, y, z);
}
float Map::GetMinHeight(PhaseShift const& phaseShift, float x, float y)
{
return m_terrain->GetMinHeight(phaseShift, x, y);
return m_terrain->GetMinHeight(phaseShift, GetId(), x, y);
}
float Map::GetGridHeight(PhaseShift const& phaseShift, float x, float y)
{
return m_terrain->GetGridHeight(phaseShift, x, y);
return m_terrain->GetGridHeight(phaseShift, GetId(), x, y);
}
float Map::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float z, bool checkVMap, float maxSearchDist)
{
return m_terrain->GetStaticHeight(phaseShift, x, y, z, checkVMap, maxSearchDist);
return m_terrain->GetStaticHeight(phaseShift, GetId(), x, y, z, checkVMap, maxSearchDist);
}
float Map::GetWaterLevel(PhaseShift const& phaseShift, float x, float y)
{
return m_terrain->GetWaterLevel(phaseShift, x, y);
return m_terrain->GetWaterLevel(phaseShift, GetId(), x, y);
}
bool Map::IsInWater(PhaseShift const& phaseShift, float x, float y, float z, LiquidData* data)
{
return m_terrain->IsInWater(phaseShift, x, y, z, data);
return m_terrain->IsInWater(phaseShift, GetId(), x, y, z, data);
}
bool Map::IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z)
{
return m_terrain->IsUnderWater(phaseShift, x, y, z);
return m_terrain->IsUnderWater(phaseShift, GetId(), x, y, z);
}
float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground, bool swim, float collisionHeight)
{
return m_terrain->GetWaterOrGroundLevel(phaseShift, x, y, z, ground, swim, collisionHeight, &_dynamicTree);
return m_terrain->GetWaterOrGroundLevel(phaseShift, GetId(), x, y, z, ground, swim, collisionHeight, &_dynamicTree);
}
bool Map::isInLineOfSight(PhaseShift const& phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
{
if ((checks & LINEOFSIGHT_CHECK_VMAP)
&& !VMAP::VMapFactory::createOrGetVMapManager()->isInLineOfSight(PhasingHandler::GetTerrainMapId(phaseShift, m_terrain.get(), x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags))
&& !VMAP::VMapFactory::createOrGetVMapManager()->isInLineOfSight(PhasingHandler::GetTerrainMapId(phaseShift, GetId(), m_terrain.get(), x1, y1), x1, y1, z1, x2, y2, z2, ignoreFlags))
return false;
if (sWorld->getBoolConfig(CONFIG_CHECK_GOBJECT_LOS) && (checks & LINEOFSIGHT_CHECK_GOBJECT)
&& !_dynamicTree.isInLineOfSight({x1, y1, z1}, {x2, y2, z2}, phaseShift))
+49 -56
View File
@@ -21,6 +21,7 @@
#include "DynamicTree.h"
#include "GridMap.h"
#include "Log.h"
#include "Memory.h"
#include "MMapFactory.h"
#include "PhasingHandler.h"
#include "Random.h"
@@ -50,29 +51,26 @@ void TerrainInfo::DiscoverGridMapFiles()
{
std::string tileListName = Trinity::StringFormat("%smaps/%03u.tilelist", sWorld->GetDataPath().c_str(), GetId());
// tile list is optional
if (FILE* tileList = fopen(tileListName.c_str(), "rb"))
if (auto tileList = Trinity::make_unique_ptr_with_deleter(fopen(tileListName.c_str(), "rb"), &::fclose))
{
u_map_magic mapMagic = { };
uint32 versionMagic = { };
uint32 build;
char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS] = { };
if (fread(mapMagic.data(), mapMagic.size(), 1, tileList) == 1
if (fread(mapMagic.data(), mapMagic.size(), 1, tileList.get()) == 1
&& mapMagic == MapMagic
&& fread(&versionMagic, sizeof(versionMagic), 1, tileList) == 1
&& fread(&versionMagic, sizeof(versionMagic), 1, tileList.get()) == 1
&& versionMagic == MapVersionMagic
&& fread(&build, sizeof(build), 1, tileList) == 1
&& fread(&tilesData[0], MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS, 1, tileList) == 1)
&& fread(&build, sizeof(build), 1, tileList.get()) == 1
&& fread(&tilesData[0], MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS, 1, tileList.get()) == 1)
{
_gridFileExists = std::bitset<MAX_NUMBER_OF_GRIDS* MAX_NUMBER_OF_GRIDS>(tilesData, std::size(tilesData));
fclose(tileList);
return;
}
fclose(tileList);
}
for (uint32 gx = 0; gx < MAX_NUMBER_OF_GRIDS; ++gx)
for (uint32 gy = 0; gy < MAX_NUMBER_OF_GRIDS; ++gy)
for (int32 gx = 0; gx < MAX_NUMBER_OF_GRIDS; ++gx)
for (int32 gy = 0; gy < MAX_NUMBER_OF_GRIDS; ++gy)
_gridFileExists[GetBitsetIndex(gx, gy)] = ExistMap(GetId(), gx, gy, false);
}
@@ -81,7 +79,7 @@ bool TerrainInfo::ExistMap(uint32 mapid, int32 gx, int32 gy, bool log /*= true*/
std::string fileName = Trinity::StringFormat("%smaps/%03u%02u%02u.map", sWorld->GetDataPath().c_str(), mapid, gx, gy);
bool ret = false;
FILE* file = fopen(fileName.c_str(), "rb");
auto file = Trinity::make_unique_ptr_with_deleter(fopen(fileName.c_str(), "rb"), &::fclose);
if (!file)
{
if (log)
@@ -92,8 +90,8 @@ bool TerrainInfo::ExistMap(uint32 mapid, int32 gx, int32 gy, bool log /*= true*/
}
else
{
map_fileheader header;
if (fread(&header, sizeof(header), 1, file) == 1)
map_fileheader header{ };
if (fread(&header, sizeof(header), 1, file.get()) == 1)
{
if (header.mapMagic != MapMagic || header.versionMagic != MapVersionMagic)
{
@@ -104,7 +102,6 @@ bool TerrainInfo::ExistMap(uint32 mapid, int32 gx, int32 gy, bool log /*= true*/
else
ret = true;
}
fclose(file);
}
return ret;
@@ -302,12 +299,12 @@ static bool IsInWMOInterior(uint32 mogpFlags)
return (mogpFlags & 0x2000) != 0;
}
void TerrainInfo::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, map_liquidHeaderTypeFlags reqLiquidType, float collisionHeight)
void TerrainInfo::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, PositionFullTerrainStatus& data, map_liquidHeaderTypeFlags reqLiquidType, float collisionHeight)
{
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
VMAP::AreaAndLiquidData vmapData;
VMAP::AreaAndLiquidData* wmoData = nullptr;
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y);
GridMap* gmap = GetGrid(terrainMapId, x, y);
vmgr->getAreaAndLiquidData(terrainMapId, x, y, z, AsUnderlyingType(reqLiquidType), vmapData);
@@ -432,7 +429,7 @@ void TerrainInfo::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift,
}
}
ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data, float collisionHeight)
ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data, float collisionHeight)
{
ZLiquidStatus result = LIQUID_MAP_NO_WATER;
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
@@ -441,7 +438,7 @@ ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, float x
uint32 liquid_type = 0;
uint32 mogpFlags = 0;
bool useGridLiquid = true;
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y);
if (vmgr->GetLiquidLevel(terrainMapId, x, y, z, AsUnderlyingType(ReqLiquidType), liquid_level, ground_level, liquid_type, mogpFlags))
{
useGridLiquid = !IsInWMOInterior(mogpFlags);
@@ -462,7 +459,7 @@ ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, float x
if (liquid_type && liquid_type < 21)
{
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(phaseShift, x, y, z)))
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(phaseShift, mapId, x, y, z)))
{
uint32 overrideLiquid = area->LiquidTypeID[liquidFlagType];
if (!overrideLiquid && area->ParentAreaID)
@@ -524,11 +521,11 @@ ZLiquidStatus TerrainInfo::GetLiquidStatus(PhaseShift const& phaseShift, float x
return result;
}
bool TerrainInfo::GetAreaInfo(PhaseShift const& phaseShift, float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId)
bool TerrainInfo::GetAreaInfo(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId)
{
float vmap_z = z;
float check_z = z;
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y);
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
uint32 vflags;
int32 vadtId;
@@ -556,16 +553,16 @@ bool TerrainInfo::GetAreaInfo(PhaseShift const& phaseShift, float x, float y, fl
return false;
}
uint32 TerrainInfo::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z)
uint32 TerrainInfo::GetAreaId(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z)
{
uint32 mogpFlags;
int32 adtId, rootId, groupId;
float vmapZ = z;
bool hasVmapArea = GetAreaInfo(phaseShift, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
bool hasVmapArea = GetAreaInfo(phaseShift, mapId, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
uint32 gridAreaId = 0;
float gridMapHeight = INVALID_HEIGHT;
if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y), x, y))
{
gridAreaId = gmap->getArea(x, y);
gridMapHeight = gmap->getHeight(x, y);
@@ -592,9 +589,9 @@ uint32 TerrainInfo::GetAreaId(PhaseShift const& phaseShift, float x, float y, fl
return areaId;
}
uint32 TerrainInfo::GetZoneId(PhaseShift const& phaseShift, float x, float y, float z)
uint32 TerrainInfo::GetZoneId(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z)
{
uint32 areaId = GetAreaId(phaseShift, x, y, z);
uint32 areaId = GetAreaId(phaseShift, mapId, x, y, z);
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
if (area->ParentAreaID)
return area->ParentAreaID;
@@ -602,36 +599,36 @@ uint32 TerrainInfo::GetZoneId(PhaseShift const& phaseShift, float x, float y, fl
return areaId;
}
void TerrainInfo::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, float x, float y, float z)
void TerrainInfo::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32 mapId, uint32& zoneid, uint32& areaid, float x, float y, float z)
{
areaid = zoneid = GetAreaId(phaseShift, x, y, z);
areaid = zoneid = GetAreaId(phaseShift, mapId, x, y, z);
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaid))
if (area->ParentAreaID)
zoneid = area->ParentAreaID;
}
float TerrainInfo::GetMinHeight(PhaseShift const& phaseShift, float x, float y)
float TerrainInfo::GetMinHeight(PhaseShift const& phaseShift, uint32 mapId, float x, float y)
{
if (GridMap const* grid = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
if (GridMap const* grid = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y), x, y))
return grid->getMinHeight(x, y);
return -500.0f;
}
float TerrainInfo::GetGridHeight(PhaseShift const& phaseShift, float x, float y)
float TerrainInfo::GetGridHeight(PhaseShift const& phaseShift, uint32 mapId, float x, float y)
{
if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y), x, y))
return gmap->getHeight(x, y);
return VMAP_INVALID_HEIGHT_VALUE;
}
float TerrainInfo::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/)
float TerrainInfo::GetStaticHeight(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/)
{
// find raw .map surface under Z coordinates
float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
float gridHeight = GetGridHeight(phaseShift, x, y);
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y);
float gridHeight = GetGridHeight(phaseShift, mapId, x, y);
if (G3D::fuzzyGe(z, gridHeight - GROUND_HEIGHT_TOLERANCE))
mapHeight = gridHeight;
@@ -665,32 +662,32 @@ float TerrainInfo::GetStaticHeight(PhaseShift const& phaseShift, float x, float
return mapHeight; // explicitly use map data
}
float TerrainInfo::GetWaterLevel(PhaseShift const& phaseShift, float x, float y)
float TerrainInfo::GetWaterLevel(PhaseShift const& phaseShift, uint32 mapId, float x, float y)
{
if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y), x, y))
return gmap->getLiquidLevel(x, y);
else
return 0;
return 0;
}
bool TerrainInfo::IsInWater(PhaseShift const& phaseShift, float x, float y, float pZ, LiquidData* data)
bool TerrainInfo::IsInWater(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float pZ, LiquidData* data)
{
LiquidData liquid_status;
LiquidData* liquid_ptr = data ? data : &liquid_status;
return (GetLiquidStatus(phaseShift, x, y, pZ, map_liquidHeaderTypeFlags::AllLiquids, liquid_ptr) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) != 0;
return (GetLiquidStatus(phaseShift, mapId, x, y, pZ, map_liquidHeaderTypeFlags::AllLiquids, liquid_ptr) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) != 0;
}
bool TerrainInfo::IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z)
bool TerrainInfo::IsUnderWater(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z)
{
return (GetLiquidStatus(phaseShift, x, y, z, map_liquidHeaderTypeFlags::Water | map_liquidHeaderTypeFlags::Ocean) & LIQUID_MAP_UNDER_WATER) != 0;
return (GetLiquidStatus(phaseShift, mapId, x, y, z, map_liquidHeaderTypeFlags::Water | map_liquidHeaderTypeFlags::Ocean) & LIQUID_MAP_UNDER_WATER) != 0;
}
float TerrainInfo::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/, DynamicMapTree const* dynamicMapTree /*= nullptr*/)
float TerrainInfo::GetWaterOrGroundLevel(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/, DynamicMapTree const* dynamicMapTree /*= nullptr*/)
{
if (GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
if (GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, mapId, this, x, y), x, y))
{
// we need ground level (including grid height version) for proper return water level in point
float ground_z = GetStaticHeight(phaseShift, x, y, z + Z_OFFSET_FIND_HEIGHT, true, 50.0f);
float ground_z = GetStaticHeight(phaseShift, mapId, x, y, z + Z_OFFSET_FIND_HEIGHT, true, 50.0f);
if (dynamicMapTree)
ground_z = std::max(ground_z, dynamicMapTree->getHeight(x, y, z + Z_OFFSET_FIND_HEIGHT, 50.0f, phaseShift));
@@ -699,7 +696,7 @@ float TerrainInfo::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x,
LiquidData liquid_status;
ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, map_liquidHeaderTypeFlags::AllLiquids, &liquid_status, collisionHeight);
ZLiquidStatus res = GetLiquidStatus(phaseShift, mapId, x, y, ground_z, map_liquidHeaderTypeFlags::AllLiquids, &liquid_status, collisionHeight);
switch (res)
{
case LIQUID_MAP_ABOVE_WATER:
@@ -714,13 +711,9 @@ float TerrainInfo::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x,
return VMAP_INVALID_HEIGHT_VALUE;
}
TerrainMgr::TerrainMgr()
{
}
TerrainMgr::TerrainMgr() = default;
TerrainMgr::~TerrainMgr()
{
}
TerrainMgr::~TerrainMgr() = default;
TerrainMgr& TerrainMgr::Instance()
{
@@ -775,21 +768,21 @@ void TerrainMgr::Update(uint32 diff)
uint32 TerrainMgr::GetAreaId(PhaseShift const& phaseShift, uint32 mapid, float x, float y, float z)
{
if (std::shared_ptr<TerrainInfo> t = LoadTerrain(mapid))
return t->GetAreaId(phaseShift, x, y, z);
return t->GetAreaId(phaseShift, mapid, x, y, z);
return 0;
}
uint32 TerrainMgr::GetZoneId(PhaseShift const& phaseShift, uint32 mapid, float x, float y, float z)
{
if (std::shared_ptr<TerrainInfo> t = LoadTerrain(mapid))
return t->GetZoneId(phaseShift, x, y, z);
return t->GetZoneId(phaseShift, mapid, x, y, z);
return 0;
}
void TerrainMgr::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, uint32 mapid, float x, float y, float z)
{
if (std::shared_ptr<TerrainInfo> t = LoadTerrain(mapid))
t->GetZoneAndAreaId(phaseShift, zoneid, areaid, x, y, z);
t->GetZoneAndAreaId(phaseShift, mapid, zoneid, areaid, x, y, z);
}
std::shared_ptr<TerrainInfo> TerrainMgr::LoadTerrainImpl(uint32 mapId)
+17 -17
View File
@@ -75,27 +75,27 @@ private:
public:
void CleanUpGrids(uint32 diff);
void GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, map_liquidHeaderTypeFlags reqLiquidType = map_liquidHeaderTypeFlags::AllLiquids, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
ZLiquidStatus GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data = nullptr, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
void GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, PositionFullTerrainStatus& data, map_liquidHeaderTypeFlags reqLiquidType = map_liquidHeaderTypeFlags::AllLiquids, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
ZLiquidStatus GetLiquidStatus(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData* data = nullptr, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
bool GetAreaInfo(PhaseShift const& phaseShift, float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId);
uint32 GetAreaId(PhaseShift const& phaseShift, float x, float y, float z);
uint32 GetAreaId(PhaseShift const& phaseShift, Position const& pos) { return GetAreaId(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
uint32 GetZoneId(PhaseShift const& phaseShift, float x, float y, float z);
uint32 GetZoneId(PhaseShift const& phaseShift, Position const& pos) { return GetZoneId(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
void GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, float x, float y, float z);
void GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, Position const& pos) { GetZoneAndAreaId(phaseShift, zoneid, areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
bool GetAreaInfo(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId);
uint32 GetAreaId(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z);
uint32 GetAreaId(PhaseShift const& phaseShift, uint32 mapId, Position const& pos) { return GetAreaId(phaseShift, mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
uint32 GetZoneId(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z);
uint32 GetZoneId(PhaseShift const& phaseShift, uint32 mapId, Position const& pos) { return GetZoneId(phaseShift, mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
void GetZoneAndAreaId(PhaseShift const& phaseShift, uint32 mapId, uint32& zoneid, uint32& areaid, float x, float y, float z);
void GetZoneAndAreaId(PhaseShift const& phaseShift, uint32 mapId, uint32& zoneid, uint32& areaid, Position const& pos) { GetZoneAndAreaId(phaseShift, mapId, zoneid, areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
float GetMinHeight(PhaseShift const& phaseShift, float x, float y);
float GetGridHeight(PhaseShift const& phaseShift, float x, float y);
float GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH);
float GetStaticHeight(PhaseShift const& phaseShift, Position const& pos, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) { return GetStaticHeight(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), checkVMap, maxSearchDist); }
float GetMinHeight(PhaseShift const& phaseShift, uint32 mapId, float x, float y);
float GetGridHeight(PhaseShift const& phaseShift, uint32 mapId, float x, float y);
float GetStaticHeight(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH);
float GetStaticHeight(PhaseShift const& phaseShift, uint32 mapId, Position const& pos, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) { return GetStaticHeight(phaseShift, mapId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), checkVMap, maxSearchDist); }
float GetWaterLevel(PhaseShift const& phaseShift, float x, float y);
bool IsInWater(PhaseShift const& phaseShift, float x, float y, float z, LiquidData* data = nullptr);
bool IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z);
float GetWaterLevel(PhaseShift const& phaseShift, uint32 mapId, float x, float y);
bool IsInWater(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, LiquidData* data = nullptr);
bool IsUnderWater(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z);
float GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground = nullptr, bool swim = false, float collisionHeight = 2.03128f, DynamicMapTree const* dynamicMapTree = nullptr); // DEFAULT_COLLISION_HEIGHT in Object.h
float GetWaterOrGroundLevel(PhaseShift const& phaseShift, uint32 mapId, float x, float y, float z, float* ground = nullptr, bool swim = false, float collisionHeight = 2.03128f, DynamicMapTree const* dynamicMapTree = nullptr); // DEFAULT_COLLISION_HEIGHT in Object.h
private:
static constexpr int32 GetBitsetIndex(int32 gx, int32 gy) { return gx * MAX_NUMBER_OF_GRIDS + gy; }
+1 -1
View File
@@ -40,7 +40,7 @@ PathGenerator::PathGenerator(WorldObject const* owner) :
TC_LOG_DEBUG("maps.mmaps", "++ PathGenerator::PathGenerator for %u", _source->GetGUID().GetCounter());
uint32 mapId = PhasingHandler::GetTerrainMapId(_source->GetPhaseShift(), _source->GetMap()->GetTerrain(), _source->GetPositionX(), _source->GetPositionY());
uint32 mapId = PhasingHandler::GetTerrainMapId(_source->GetPhaseShift(), _source->GetMapId(), _source->GetMap()->GetTerrain(), _source->GetPositionX(), _source->GetPositionY());
if (DisableMgr::IsPathfindingEnabled(mapId))
{
MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager();
+3 -3
View File
@@ -474,10 +474,10 @@ bool PhasingHandler::InDbPhaseShift(WorldObject const* object, uint8 phaseUseFla
return object->GetPhaseShift().CanSee(phaseShift);
}
uint32 PhasingHandler::GetTerrainMapId(PhaseShift const& phaseShift, TerrainInfo const* terrain, float x, float y)
uint32 PhasingHandler::GetTerrainMapId(PhaseShift const& phaseShift, uint32 mapId, TerrainInfo const* terrain, float x, float y)
{
if (phaseShift.VisibleMapIds.empty())
return terrain->GetId();
return mapId;
if (phaseShift.VisibleMapIds.size() == 1)
return phaseShift.VisibleMapIds.begin()->first;
@@ -490,7 +490,7 @@ uint32 PhasingHandler::GetTerrainMapId(PhaseShift const& phaseShift, TerrainInfo
if (terrain->HasChildTerrainGridFile(visibleMap.first, gx, gy))
return visibleMap.first;
return terrain->GetId();
return mapId;
}
void PhasingHandler::SetAlwaysVisible(PhaseShift& phaseShift, bool apply)
+1 -1
View File
@@ -62,7 +62,7 @@ public:
static void InitDbVisibleMapId(PhaseShift& phaseShift, int32 visibleMapId);
static bool InDbPhaseShift(WorldObject const* object, uint8 phaseUseFlags, uint16 phaseId, uint32 phaseGroupId);
static uint32 GetTerrainMapId(PhaseShift const& phaseShift, TerrainInfo const* terrain, float x, float y);
static uint32 GetTerrainMapId(PhaseShift const& phaseShift, uint32 mapId, TerrainInfo const* terrain, float x, float y);
static void SetAlwaysVisible(PhaseShift& phaseShift, bool apply);
static void SetInversed(PhaseShift& phaseShift, bool apply);
+3 -3
View File
@@ -247,7 +247,7 @@ public:
player->SaveRecallPosition();
std::shared_ptr<TerrainInfo> terrain = sTerrainMgr.LoadTerrain(mapId);
float z = std::max(terrain->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), terrain->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
float z = std::max(terrain->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), mapId, x, y, MAX_HEIGHT), terrain->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), mapId, x, y));
player->TeleportTo(mapId, x, y, z, player->GetOrientation());
return true;
@@ -343,7 +343,7 @@ public:
else
player->SaveRecallPosition();
float z = std::max(terrain->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), terrain->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
float z = std::max(terrain->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), zoneEntry->ContinentID, x, y, MAX_HEIGHT), terrain->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), zoneEntry->ContinentID, x, y));
player->TeleportTo(zoneEntry->ContinentID, x, y, z, player->GetOrientation());
return true;
@@ -373,7 +373,7 @@ public:
return false;
}
std::shared_ptr<TerrainInfo> terrain = sTerrainMgr.LoadTerrain(mapId);
z = std::max(terrain->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), terrain->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
z = std::max(terrain->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), mapId, x, y, MAX_HEIGHT), terrain->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), mapId, x, y));
}
return DoTeleport(handler, { x, y, *z, o.value_or(0.0f) }, mapId);
+3 -3
View File
@@ -139,7 +139,7 @@ public:
handler->PSendSysMessage("gridloc [%i, %i]", gy, gx);
// calculate navmesh tile location
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMap()->GetTerrain(), x, y);
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMapId(), player->GetMap()->GetTerrain(), x, y);
dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(terrainMapId);
dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(terrainMapId, player->GetInstanceId());
if (!navmesh || !navmeshquery)
@@ -190,7 +190,7 @@ public:
static bool HandleMmapLoadedTilesCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMap()->GetTerrain(), player->GetPositionX(), player->GetPositionY());
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMapId(), player->GetMap()->GetTerrain(), player->GetPositionX(), player->GetPositionY());
dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(terrainMapId);
dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(terrainMapId, player->GetInstanceId());
if (!navmesh || !navmeshquery)
@@ -216,7 +216,7 @@ public:
static bool HandleMmapStatsCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMap()->GetTerrain(), player->GetPositionX(), player->GetPositionY());
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(player->GetPhaseShift(), player->GetMapId(), player->GetMap()->GetTerrain(), player->GetPositionX(), player->GetPositionY());
handler->PSendSysMessage("mmap stats:");
handler->PSendSysMessage(" global mmap pathfinding is %sabled", DisableMgr::IsPathfindingEnabled(player->GetMapId()) ? "en" : "dis");