diff options
author | Shauren <shauren.trinity@gmail.com> | 2020-05-24 22:34:25 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2020-05-24 22:34:25 +0200 |
commit | eba31dea27b7fdc4a49c024898ef3a01bcbc7295 (patch) | |
tree | 4be401cb2969769c92b571e1b8d04555f633693e /src/server/game/Maps/Map.cpp | |
parent | ebb6f12db811d78a538982cca9b8cc1887fc2527 (diff) |
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)
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r-- | src/server/game/Maps/Map.cpp | 210 |
1 files changed, 115 insertions, 95 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 24392412710..5e00ed3b83e 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -90,7 +90,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/%04u_%02u_%02u.map", sWorld->GetDataPath().c_str(), mapid, gx, gy); @@ -98,8 +114,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 { @@ -107,8 +126,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; } @@ -181,6 +203,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); } @@ -190,29 +213,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/%04u_%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) @@ -225,25 +251,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() @@ -517,7 +536,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 @@ -530,7 +549,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]; + } + } } } @@ -1827,9 +1861,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()); @@ -1916,7 +1954,6 @@ GridMap::GridMap() _liquidEntry = nullptr; _liquidFlags = nullptr; _liquidMap = nullptr; - _fileExists = false; } GridMap::~GridMap() @@ -1924,7 +1961,7 @@ GridMap::~GridMap() unloadData(); } -bool GridMap::loadData(const char* filename) +GridMap::LoadResult GridMap::loadData(const char* filename) { // Unload old data if exist unloadData(); @@ -1933,13 +1970,12 @@ bool GridMap::loadData(const char* 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) @@ -1949,30 +1985,30 @@ bool GridMap::loadData(const char* 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; } 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() @@ -1992,7 +2028,6 @@ void GridMap::unloadData() _liquidFlags = nullptr; _liquidMap = nullptr; _gridGetHeight = &GridMap::getHeightFromFlat; - _fileExists = false; } bool GridMap::loadAreaData(FILE* in, uint32 offset, uint32 /*size*/) @@ -2524,23 +2559,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 @@ -2548,23 +2568,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]->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*/) const +float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/) { - if (const_cast<Map*>(this)->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, true, 50.0f); @@ -2580,12 +2600,12 @@ 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 float mapHeight = VMAP_INVALID_HEIGHT_VALUE; uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y); - if (GridMap* gmap = m_parentTerrainMap->GetGrid(terrainMapId, x, y)) + if (GridMap* gmap = GetGrid(terrainMapId, x, y)) { float gridHeight = gmap->getHeight(x, y); // look from a bit higher pos to find the floor, ignore under surface case @@ -2623,9 +2643,9 @@ 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; @@ -2655,7 +2675,7 @@ inline bool IsOutdoorWMO(uint32 mogpFlags, int32 /*adtId*/, int32 /*rootId*/, in return outdoor; } -bool Map::IsOutdoors(PhaseShift const& phaseShift, float x, float y, float z) const +bool Map::IsOutdoors(PhaseShift const& phaseShift, float x, float y, float z) { uint32 mogpFlags; int32 adtId, rootId, groupId; @@ -2674,7 +2694,7 @@ bool Map::IsOutdoors(PhaseShift const& phaseShift, float x, float y, float z) co return IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry); } -bool Map::GetAreaInfo(PhaseShift const& phaseShift, float x, float y, float z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const +bool Map::GetAreaInfo(PhaseShift const& phaseShift, float x, float y, float z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) { float vmap_z = z; float dynamic_z = z; @@ -2710,7 +2730,7 @@ bool Map::GetAreaInfo(PhaseShift const& phaseShift, float x, float y, float z, u if (hasVmapAreaInfo || hasDynamicAreaInfo) { // check if there's terrain between player height and object height - if (GridMap* gmap = m_parentTerrainMap->GetGrid(terrainMapId, x, y)) + if (GridMap* gmap = GetGrid(terrainMapId, x, y)) { float mapHeight = gmap->getHeight(x, y); // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice... @@ -2722,7 +2742,7 @@ bool Map::GetAreaInfo(PhaseShift const& phaseShift, float x, float y, float z, u return false; } -uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z, bool *isOutdoors) const +uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z, bool *isOutdoors) { uint32 mogpFlags; int32 adtId, rootId, groupId; @@ -2744,7 +2764,7 @@ uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z, b if (!areaId) { - 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)) areaId = gmap->getArea(x, y); // this used while not all *.map files generated (instances) @@ -2762,12 +2782,12 @@ uint32 Map::GetAreaId(PhaseShift const& phaseShift, float x, float y, float z, b return areaId; } -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) { return GetAreaId(phaseShift, x, y, z, nullptr); } -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)) @@ -2777,7 +2797,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)) @@ -2785,15 +2805,15 @@ void Map::GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& zoneid = area->ParentAreaID; } -uint8 Map::GetTerrainType(PhaseShift const& phaseShift, float x, float y) const +uint8 Map::GetTerrainType(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->getTerrainType(x, y); else return 0; } -ZLiquidStatus Map::getLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, uint8 ReqLiquidType, LiquidData* data) const +ZLiquidStatus Map::getLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, uint8 ReqLiquidType, LiquidData* data) { ZLiquidStatus result = LIQUID_MAP_NO_WATER; VMAP::IVMapManager* vmgr = VMAP::VMapFactory::createOrGetVMapManager(); @@ -2858,7 +2878,7 @@ ZLiquidStatus Map::getLiquidStatus(PhaseShift const& phaseShift, float x, float } } - 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); @@ -2879,9 +2899,9 @@ ZLiquidStatus Map::getLiquidStatus(PhaseShift const& phaseShift, float x, float return result; } -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; @@ -2907,19 +2927,19 @@ bool Map::getObjectHitPos(PhaseShift const& phaseShift, float x1, float y1, floa return result; } -float Map::GetHeight(PhaseShift const& phaseShift, float x, float y, float z, bool vmap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) const +float Map::GetHeight(PhaseShift const& phaseShift, float x, float y, float z, bool vmap /*= true*/, float maxSearchDist /*= DEFAULT_HEIGHT_SEARCH*/) { return std::max<float>(GetStaticHeight(phaseShift, x, y, z, vmap, maxSearchDist), _dynamicTree.getHeight(x, y, z, maxSearchDist, phaseShift)); } -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; } |