Core/Maps: Improvements to terrain swap handling
* Fixed memory leak when unloading grids * Handle child maps being entered * Allow chaining more child maps (Draenor -> Tanaan Jungle -> Tanaan Jungle - No Hubs Phase)
This commit is contained in:
1 parent
8adca7637b
commit
40f80fc0ed
13 files changed
+185
-159
No files matched your search
+112
-93
@@ -96,7 +96,23 @@ Map::~Map()
|
||||
MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(GetId(), i_InstanceId);
|
||||
}
|
||||
|
||||
bool Map::ExistMap(uint32 mapid, int gx, int gy)
|
||||
void Map::DiscoverGridMapFiles()
|
||||
{
|
||||
for (uint32 gx = 0; gx < MAX_NUMBER_OF_GRIDS; ++gx)
|
||||
for (uint32 gy = 0; gy < MAX_NUMBER_OF_GRIDS; ++gy)
|
||||
i_gridFileExists[gx * MAX_NUMBER_OF_GRIDS + gy] = ExistMap(GetId(), gx, gy, false);
|
||||
}
|
||||
|
||||
Map* Map::GetRootParentTerrainMap()
|
||||
{
|
||||
Map* map = this;
|
||||
while (map != map->m_parentTerrainMap)
|
||||
map = map->m_parentTerrainMap;
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
bool Map::ExistMap(uint32 mapid, int gx, int gy, bool log /*= true*/)
|
||||
{
|
||||
std::string fileName = Trinity::StringFormat("%smaps/%03u%02u%02u.map", sWorld->GetDataPath().c_str(), mapid, gx, gy);
|
||||
|
||||
@@ -104,8 +120,11 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy)
|
||||
FILE* file = fopen(fileName.c_str(), "rb");
|
||||
if (!file)
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Map file '%s' does not exist!", fileName.c_str());
|
||||
TC_LOG_ERROR("maps", "Please place MAP-files (*.map) in the appropriate directory (%s), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath()+"maps/").c_str());
|
||||
if (log)
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Map file '%s' does not exist!", fileName.c_str());
|
||||
TC_LOG_ERROR("maps", "Please place MAP-files (*.map) in the appropriate directory (%s), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath()+"maps/").c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -113,8 +132,11 @@ bool Map::ExistMap(uint32 mapid, int gx, int gy)
|
||||
if (fread(&header, sizeof(header), 1, file) == 1)
|
||||
{
|
||||
if (header.mapMagic.asUInt != MapMagic.asUInt || header.versionMagic.asUInt != MapVersionMagic.asUInt)
|
||||
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
|
||||
fileName.c_str(), 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
|
||||
{
|
||||
if (log)
|
||||
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
|
||||
fileName.c_str(), 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
|
||||
}
|
||||
else
|
||||
ret = true;
|
||||
}
|
||||
@@ -187,6 +209,7 @@ void Map::LoadVMap(int gx, int gy)
|
||||
void Map::LoadMap(int gx, int gy)
|
||||
{
|
||||
LoadMapImpl(this, gx, gy);
|
||||
|
||||
for (Map* childBaseMap : *m_childTerrainMaps)
|
||||
childBaseMap->LoadMap(gx, gy);
|
||||
}
|
||||
@@ -196,29 +219,32 @@ void Map::LoadMapImpl(Map* map, int gx, int gy)
|
||||
if (map->GridMaps[gx][gy])
|
||||
return;
|
||||
|
||||
Map* parent = map->m_parentMap;
|
||||
++parent->GridMapReference[gx][gy];
|
||||
|
||||
// load grid map for base map
|
||||
if (parent != map)
|
||||
{
|
||||
GridCoord ngridCoord = GridCoord((MAX_NUMBER_OF_GRIDS - 1) - gx, (MAX_NUMBER_OF_GRIDS - 1) - gy);
|
||||
if (!parent->GridMaps[gx][gy])
|
||||
parent->EnsureGridCreated(ngridCoord);
|
||||
|
||||
map->GridMaps[gx][gy] = parent->GridMaps[gx][gy];
|
||||
return;
|
||||
}
|
||||
|
||||
// map file name
|
||||
std::string fileName = Trinity::StringFormat("%smaps/%03u%02u%02u.map", sWorld->GetDataPath().c_str(), map->GetId(), gx, gy);
|
||||
TC_LOG_DEBUG("maps", "Loading map %s", fileName.c_str());
|
||||
// loading data
|
||||
map->GridMaps[gx][gy] = new GridMap();
|
||||
if (!map->GridMaps[gx][gy]->loadData(fileName.c_str()))
|
||||
TC_LOG_ERROR("maps", "Error loading map file: %s", fileName.c_str());
|
||||
std::shared_ptr<GridMap> gridMap = std::make_shared<GridMap>();
|
||||
GridMap::LoadResult gridMapLoadResult = gridMap->loadData(fileName.c_str());
|
||||
if (gridMapLoadResult == GridMap::LoadResult::Ok)
|
||||
map->GridMaps[gx][gy] = std::move(gridMap);
|
||||
else
|
||||
{
|
||||
map->i_gridFileExists[gx * MAX_NUMBER_OF_GRIDS + gy] = false;
|
||||
Map* parentTerrain = map;
|
||||
while (parentTerrain != parentTerrain->m_parentTerrainMap)
|
||||
{
|
||||
map->GridMaps[gx][gy] = parentTerrain->m_parentTerrainMap->GridMaps[gx][gy];
|
||||
if (map->GridMaps[gx][gy])
|
||||
break;
|
||||
|
||||
sScriptMgr->OnLoadGridMap(map, map->GridMaps[gx][gy], gx, gy);
|
||||
parentTerrain = parentTerrain->m_parentTerrainMap;
|
||||
}
|
||||
}
|
||||
|
||||
if (map->GridMaps[gx][gy])
|
||||
sScriptMgr->OnLoadGridMap(map, map->GridMaps[gx][gy].get(), gx, gy);
|
||||
else if (gridMapLoadResult == GridMap::LoadResult::InvalidFile)
|
||||
TC_LOG_ERROR("maps", "Error loading map file: %s", fileName.c_str());
|
||||
}
|
||||
|
||||
void Map::UnloadMap(int gx, int gy)
|
||||
@@ -231,25 +257,18 @@ void Map::UnloadMap(int gx, int gy)
|
||||
|
||||
void Map::UnloadMapImpl(Map* map, int gx, int gy)
|
||||
{
|
||||
if (map->GridMaps[gx][gy])
|
||||
{
|
||||
Map* parent = map->m_parentMap;
|
||||
if (!--parent->GridMapReference[gx][gy])
|
||||
{
|
||||
parent->GridMaps[gx][gy]->unloadData();
|
||||
delete parent->GridMaps[gx][gy];
|
||||
parent->GridMaps[gx][gy] = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
map->GridMaps[gx][gy] = nullptr;
|
||||
}
|
||||
|
||||
void Map::LoadMapAndVMap(int gx, int gy)
|
||||
{
|
||||
LoadMap(gx, gy);
|
||||
LoadVMap(gx, gy);
|
||||
LoadMMap(gx, gy);
|
||||
// Only load the data for the base map
|
||||
if (this == m_parentMap)
|
||||
{
|
||||
LoadVMap(gx, gy);
|
||||
LoadMMap(gx, gy);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::LoadAllCells()
|
||||
@@ -518,7 +537,7 @@ void Map::EnsureGridCreated_i(const GridCoord &p)
|
||||
{
|
||||
TC_LOG_DEBUG("maps", "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
|
||||
|
||||
NGridType* ngrid = new NGridType(p.x_coord*MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld->getBoolConfig(CONFIG_GRID_UNLOAD));
|
||||
NGridType* ngrid = new NGridType(p.x_coord * MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld->getBoolConfig(CONFIG_GRID_UNLOAD));
|
||||
setNGrid(ngrid, p.x_coord, p.y_coord);
|
||||
|
||||
// build a linkage between this map and NGridType
|
||||
@@ -531,7 +550,22 @@ void Map::EnsureGridCreated_i(const GridCoord &p)
|
||||
int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord;
|
||||
|
||||
if (!GridMaps[gx][gy])
|
||||
m_parentTerrainMap->LoadMapAndVMap(gx, gy);
|
||||
{
|
||||
Map* rootParentTerrainMap = m_parentMap->GetRootParentTerrainMap();
|
||||
// because LoadMapAndVMap is always entered using rootParentTerrainMap, we can only lock that once and not have to do it for every child map
|
||||
std::unique_lock<std::mutex> lock(rootParentTerrainMap->_gridLock, std::defer_lock);
|
||||
if (this != rootParentTerrainMap)
|
||||
lock.lock();
|
||||
|
||||
if (!m_parentMap->GridMaps[gx][gy])
|
||||
rootParentTerrainMap->LoadMapAndVMap(gx, gy);
|
||||
|
||||
if (m_parentMap->GridMaps[gx][gy])
|
||||
{
|
||||
GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy];
|
||||
++rootParentTerrainMap->GridMapReference[gx][gy];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1732,9 +1766,13 @@ bool Map::UnloadGrid(NGridType& ngrid, bool unloadAll)
|
||||
// delete grid map, but don't delete if it is from parent map (and thus only reference)
|
||||
if (GridMaps[gx][gy])
|
||||
{
|
||||
m_parentTerrainMap->UnloadMap(gx, gy);
|
||||
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(m_parentTerrainMap->GetId(), gx, gy);
|
||||
MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(m_parentTerrainMap->GetId(), gx, gy);
|
||||
Map* terrainRoot = m_parentMap->GetRootParentTerrainMap();
|
||||
if (!--terrainRoot->GridMapReference[gx][gy])
|
||||
{
|
||||
m_parentMap->GetRootParentTerrainMap()->UnloadMap(gx, gy);
|
||||
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(terrainRoot->GetId(), gx, gy);
|
||||
MMAP::MMapFactory::createOrGetMMapManager()->unloadMap(terrainRoot->GetId(), gx, gy);
|
||||
}
|
||||
}
|
||||
|
||||
TC_LOG_DEBUG("maps", "Unloading grid[%u, %u] for map %u finished", x, y, GetId());
|
||||
@@ -1822,7 +1860,6 @@ GridMap::GridMap()
|
||||
_liquidFlags = nullptr;
|
||||
_liquidMap = nullptr;
|
||||
_holes = nullptr;
|
||||
_fileExists = false;
|
||||
}
|
||||
|
||||
GridMap::~GridMap()
|
||||
@@ -1830,7 +1867,7 @@ GridMap::~GridMap()
|
||||
unloadData();
|
||||
}
|
||||
|
||||
bool GridMap::loadData(char const* filename)
|
||||
GridMap::LoadResult GridMap::loadData(const char* filename)
|
||||
{
|
||||
// Unload old data if exist
|
||||
unloadData();
|
||||
@@ -1839,13 +1876,12 @@ bool GridMap::loadData(char const* filename)
|
||||
// Not return error if file not found
|
||||
FILE* in = fopen(filename, "rb");
|
||||
if (!in)
|
||||
return true;
|
||||
return LoadResult::FileDoesNotExist;
|
||||
|
||||
_fileExists = true;
|
||||
if (fread(&header, sizeof(header), 1, in) != 1)
|
||||
{
|
||||
fclose(in);
|
||||
return false;
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
|
||||
if (header.mapMagic.asUInt == MapMagic.asUInt && header.versionMagic.asUInt == MapVersionMagic.asUInt)
|
||||
@@ -1855,37 +1891,37 @@ bool GridMap::loadData(char const* filename)
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Error loading map area data\n");
|
||||
fclose(in);
|
||||
return false;
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
// load up height data
|
||||
if (header.heightMapOffset && !loadHeightData(in, header.heightMapOffset, header.heightMapSize))
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Error loading map height data\n");
|
||||
fclose(in);
|
||||
return false;
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
// load up liquid data
|
||||
if (header.liquidMapOffset && !loadLiquidData(in, header.liquidMapOffset, header.liquidMapSize))
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Error loading map liquids data\n");
|
||||
fclose(in);
|
||||
return false;
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
// loadup holes data (if any. check header.holesOffset)
|
||||
if (header.holesSize && !loadHolesData(in, header.holesOffset, header.holesSize))
|
||||
{
|
||||
TC_LOG_ERROR("maps", "Error loading map holes data\n");
|
||||
fclose(in);
|
||||
return false;
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
fclose(in);
|
||||
return true;
|
||||
return LoadResult::Ok;
|
||||
}
|
||||
|
||||
TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
|
||||
filename, 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
|
||||
fclose(in);
|
||||
return false;
|
||||
return LoadResult::InvalidFile;
|
||||
}
|
||||
|
||||
void GridMap::unloadData()
|
||||
@@ -1907,7 +1943,6 @@ void GridMap::unloadData()
|
||||
_liquidMap = nullptr;
|
||||
_holes = nullptr;
|
||||
_gridGetHeight = &GridMap::getHeightFromFlat;
|
||||
_fileExists = false;
|
||||
}
|
||||
|
||||
bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/)
|
||||
@@ -2463,23 +2498,8 @@ inline ZLiquidStatus GridMap::GetLiquidStatus(float x, float y, float z, uint8 R
|
||||
return LIQUID_MAP_ABOVE_WATER;
|
||||
}
|
||||
|
||||
inline GridMap* Map::GetGrid(float x, float y)
|
||||
{
|
||||
// half opt method
|
||||
int gx=(int)(CENTER_GRID_ID - x/SIZE_OF_GRIDS); //grid x
|
||||
int gy=(int)(CENTER_GRID_ID - y/SIZE_OF_GRIDS); //grid y
|
||||
|
||||
// ensure GridMap is loaded
|
||||
EnsureGridCreated(GridCoord((MAX_NUMBER_OF_GRIDS - 1) - gx, (MAX_NUMBER_OF_GRIDS - 1) - gy));
|
||||
|
||||
return GridMaps[gx][gy];
|
||||
}
|
||||
|
||||
GridMap* Map::GetGrid(uint32 mapId, float x, float y)
|
||||
{
|
||||
if (GetId() == mapId)
|
||||
return GetGrid(x, y);
|
||||
|
||||
// half opt method
|
||||
int gx = (int)(CENTER_GRID_ID - x / SIZE_OF_GRIDS); //grid x
|
||||
int gy = (int)(CENTER_GRID_ID - y / SIZE_OF_GRIDS); //grid y
|
||||
@@ -2487,24 +2507,23 @@ GridMap* Map::GetGrid(uint32 mapId, float x, float y)
|
||||
// ensure GridMap is loaded
|
||||
EnsureGridCreated(GridCoord((MAX_NUMBER_OF_GRIDS - 1) - gx, (MAX_NUMBER_OF_GRIDS - 1) - gy));
|
||||
|
||||
GridMap* grid = GridMaps[gx][gy];
|
||||
|
||||
GridMap* grid = GridMaps[gx][gy].get();
|
||||
auto childMapItr = std::find_if(m_childTerrainMaps->begin(), m_childTerrainMaps->end(), [mapId](Map* childTerrainMap) { return childTerrainMap->GetId() == mapId; });
|
||||
if (childMapItr != m_childTerrainMaps->end() && (*childMapItr)->GridMaps[gx][gy] && (*childMapItr)->GridMaps[gx][gy]->fileExists())
|
||||
grid = (*childMapItr)->GridMaps[gx][gy];
|
||||
if (childMapItr != m_childTerrainMaps->end() && (*childMapItr)->GridMaps[gx][gy])
|
||||
grid = (*childMapItr)->GridMaps[gx][gy].get();
|
||||
|
||||
return grid;
|
||||
}
|
||||
|
||||
bool Map::HasGrid(uint32 mapId, int32 gx, int32 gy) const
|
||||
bool Map::HasChildMapGridFile(uint32 mapId, int32 gx, int32 gy) const
|
||||
{
|
||||
auto childMapItr = std::find_if(m_childTerrainMaps->begin(), m_childTerrainMaps->end(), [mapId](Map* childTerrainMap) { return childTerrainMap->GetId() == mapId; });
|
||||
return childMapItr != m_childTerrainMaps->end() && (*childMapItr)->GridMaps[gx][gy] && (*childMapItr)->GridMaps[gx][gy]->fileExists();
|
||||
return childMapItr != m_childTerrainMaps->end() && (*childMapItr)->i_gridFileExists[gx * MAX_NUMBER_OF_GRIDS + gy];
|
||||
}
|
||||
|
||||
float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/) const
|
||||
float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/)
|
||||
{
|
||||
if (m_parentTerrainMap->GetGrid(x, y))
|
||||
if (GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
|
||||
{
|
||||
// we need ground level (including grid height version) for proper return water level in point
|
||||
float ground_z = GetHeight(phaseShift, x, y, z + collisionHeight);
|
||||
@@ -2528,7 +2547,7 @@ float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y,
|
||||
return VMAP_INVALID_HEIGHT_VALUE;
|
||||
}
|
||||
|
||||
float Map::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const
|
||||
float Map::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float z, bool checkVMap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/)
|
||||
{
|
||||
// find raw .map surface under Z coordinates
|
||||
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
|
||||
@@ -2567,17 +2586,17 @@ float Map::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float
|
||||
return mapHeight; // explicitly use map data
|
||||
}
|
||||
|
||||
float Map::GetMinHeight(float x, float y) const
|
||||
float Map::GetMinHeight(PhaseShift const& phaseShift, float x, float y)
|
||||
{
|
||||
if (GridMap const* grid = const_cast<Map*>(this)->GetGrid(x, y))
|
||||
if (GridMap const* grid = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
|
||||
return grid->getMinHeight(x, y);
|
||||
|
||||
return -500.0f;
|
||||
}
|
||||
|
||||
float Map::GetGridHeight(uint32 mapId, float x, float y) const
|
||||
float Map::GetGridHeight(uint32 mapId, float x, float y)
|
||||
{
|
||||
if (GridMap* gmap = m_parentTerrainMap->GetGrid(mapId, x, y))
|
||||
if (GridMap* gmap = GetGrid(mapId, x, y))
|
||||
return gmap->getHeight(x, y);
|
||||
|
||||
return VMAP_INVALID_HEIGHT_VALUE;
|
||||
@@ -2588,7 +2607,7 @@ static inline bool IsInWMOInterior(uint32 mogpFlags)
|
||||
return (mogpFlags & 0x2000) != 0;
|
||||
}
|
||||
|
||||
uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z) const
|
||||
uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z)
|
||||
{
|
||||
uint32 mogpFlags;
|
||||
int32 adtId, rootId, groupId;
|
||||
@@ -2598,7 +2617,7 @@ uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z) c
|
||||
|
||||
uint32 gridAreaId = 0;
|
||||
float gridMapHeight = INVALID_HEIGHT;
|
||||
if (GridMap* gmap = m_parentTerrainMap->GetGrid(terrainMapId, x, y))
|
||||
if (GridMap* gmap = GetGrid(terrainMapId, x, y))
|
||||
{
|
||||
gridAreaId = gmap->getArea(x, y);
|
||||
gridMapHeight = gmap->getHeight(x, y);
|
||||
@@ -2625,7 +2644,7 @@ uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z) c
|
||||
return areaId;
|
||||
}
|
||||
|
||||
uint32 Map::GetZoneId(PhaseShift const& phaseShift, float x, float y, float z) const
|
||||
uint32 Map::GetZoneId(PhaseShift const& phaseShift, float x, float y, float z)
|
||||
{
|
||||
uint32 areaId = GetAreaId(phaseShift, x, y, z);
|
||||
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
|
||||
@@ -2635,7 +2654,7 @@ uint32 Map::GetZoneId(PhaseShift const& phaseShift, float x, float y, float z) c
|
||||
return areaId;
|
||||
}
|
||||
|
||||
void Map::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, float x, float y, float z) const
|
||||
void Map::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, float x, float y, float z)
|
||||
{
|
||||
areaid = zoneid = GetAreaId(phaseShift, x, y, z);
|
||||
if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaid))
|
||||
@@ -2643,7 +2662,7 @@ void Map::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32&
|
||||
zoneid = area->ParentAreaID;
|
||||
}
|
||||
|
||||
ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, uint8 ReqLiquidType, LiquidData* data, float collisionHeight) const
|
||||
ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, uint8 ReqLiquidType, LiquidData* data, float collisionHeight)
|
||||
{
|
||||
ZLiquidStatus result = LIQUID_MAP_NO_WATER;
|
||||
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
|
||||
@@ -2713,7 +2732,7 @@ ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float
|
||||
|
||||
if (useGridLiquid)
|
||||
{
|
||||
if (GridMap* gmap = m_parentTerrainMap->GetGrid(terrainMapId, x, y))
|
||||
if (GridMap* gmap = GetGrid(terrainMapId, x, y))
|
||||
{
|
||||
LiquidData map_data;
|
||||
ZLiquidStatus map_result = gmap->GetLiquidStatus(x, y, z, ReqLiquidType, &map_data, collisionHeight);
|
||||
@@ -2735,12 +2754,12 @@ ZLiquidStatus Map::GetLiquidStatus(PhaseShift const& phaseShift, float x, float
|
||||
return result;
|
||||
}
|
||||
|
||||
void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, uint8 reqLiquidType, float collisionHeight) const
|
||||
void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, uint8 reqLiquidType, float collisionHeight)
|
||||
{
|
||||
VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager();
|
||||
VMAP::AreaAndLiquidData vmapData;
|
||||
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
|
||||
GridMap* gmap = m_parentTerrainMap->GetGrid(terrainMapId, x, y);
|
||||
GridMap* gmap = GetGrid(terrainMapId, x, y);
|
||||
vmgr->getAreaAndLiquidData(terrainMapId, x, y, z, reqLiquidType, vmapData);
|
||||
|
||||
uint32 gridAreaId = 0;
|
||||
@@ -2862,9 +2881,9 @@ void Map::GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x,
|
||||
}
|
||||
}
|
||||
|
||||
float Map::GetWaterLevel(PhaseShift const& phaseShift, float x, float y) const
|
||||
float Map::GetWaterLevel(PhaseShift const& phaseShift, float x, float y)
|
||||
{
|
||||
if (GridMap* gmap = m_parentTerrainMap->GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
|
||||
if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
|
||||
return gmap->getLiquidLevel(x, y);
|
||||
else
|
||||
return 0;
|
||||
@@ -2895,14 +2914,14 @@ bool Map::getObjectHitPos(PhaseShift const& phaseShift, float x1, float y1, floa
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Map::IsInWater(PhaseShift const& phaseShift, float x, float y, float pZ, LiquidData* data) const
|
||||
bool Map::IsInWater(PhaseShift const& phaseShift, 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_ALL_LIQUIDS, liquid_ptr) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) != 0;
|
||||
}
|
||||
|
||||
bool Map::IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z) const
|
||||
bool Map::IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z)
|
||||
{
|
||||
return (GetLiquidStatus(phaseShift, x, y, z, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN) & LIQUID_MAP_UNDER_WATER) != 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user