From 16a06346aea16ffd6ee84081cedfdb0c75ac0b38 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sat, 23 Jul 2022 19:13:33 +0200 Subject: Core/Maps: Move terrain data handling out of Map class Partial port of cmangos/mangos-wotlk@ff5232c64809207b5fa59d62e9870f58a36b6f3f --- src/common/Collision/Management/VMapManager2.cpp | 57 +++--------------------- 1 file changed, 5 insertions(+), 52 deletions(-) (limited to 'src/common/Collision/Management/VMapManager2.cpp') diff --git a/src/common/Collision/Management/VMapManager2.cpp b/src/common/Collision/Management/VMapManager2.cpp index 3ab64e99251..8afd4449dce 100644 --- a/src/common/Collision/Management/VMapManager2.cpp +++ b/src/common/Collision/Management/VMapManager2.cpp @@ -78,7 +78,6 @@ namespace VMAP void VMapManager2::InitializeThreadUnsafe(std::unordered_map> const& mapData) { // the caller must pass the list of all mapIds that will be used in the VMapManager2 lifetime - iChildMapData = mapData; for (std::pair> const& mapId : mapData) { iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId.first, nullptr)); @@ -110,37 +109,11 @@ namespace VMAP return fname.str(); } - int VMapManager2::loadMap(char const* basePath, unsigned int mapId, int x, int y) + LoadResult VMapManager2::loadMap(char const* basePath, unsigned int mapId, int x, int y) { - int result = VMAP_LOAD_RESULT_IGNORED; - if (isMapLoadingEnabled()) - { - LoadResult parentLoadResult = loadSingleMap(mapId, basePath, x, y); - if (parentLoadResult == LoadResult::Success || parentLoadResult == LoadResult::FileNotFound) - { - if (parentLoadResult == LoadResult::Success) - result = VMAP_LOAD_RESULT_OK; - // else VMAP_LOAD_RESULT_IGNORED - - auto childMaps = iChildMapData.find(mapId); - if (childMaps != iChildMapData.end()) - for (uint32 childMapId : childMaps->second) - { - LoadResult childLoadResult = loadSingleMap(childMapId, basePath, x, y); - if (childLoadResult != LoadResult::Success && childLoadResult != LoadResult::FileNotFound) - result = VMAP_LOAD_RESULT_ERROR; - } - } - else - result = VMAP_LOAD_RESULT_ERROR; - } - - return result; - } + if (!isMapLoadingEnabled()) + return LoadResult::DisabledInConfig; - // load one tile (internal use only) - LoadResult VMapManager2::loadSingleMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY) - { auto instanceTree = iInstanceMapTrees.find(mapId); if (instanceTree == iInstanceMapTrees.end()) { @@ -148,7 +121,7 @@ namespace VMAP instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, nullptr)).first; else ABORT_MSG("Invalid mapId %u tile [%u, %u] passed to VMapManager2 after startup in thread unsafe environment", - mapId, tileX, tileY); + mapId, x, y); } if (!instanceTree->second) @@ -164,20 +137,10 @@ namespace VMAP instanceTree->second = newTree; } - return instanceTree->second->LoadMapTile(tileX, tileY, this); + return instanceTree->second->LoadMapTile(x, y, this); } void VMapManager2::unloadMap(unsigned int mapId, int x, int y) - { - auto childMaps = iChildMapData.find(mapId); - if (childMaps != iChildMapData.end()) - for (uint32 childMapId : childMaps->second) - unloadSingleMap(childMapId, x, y); - - unloadSingleMap(mapId, x, y); - } - - void VMapManager2::unloadSingleMap(uint32 mapId, int x, int y) { auto instanceTree = iInstanceMapTrees.find(mapId); if (instanceTree != iInstanceMapTrees.end() && instanceTree->second) @@ -192,16 +155,6 @@ namespace VMAP } void VMapManager2::unloadMap(unsigned int mapId) - { - auto childMaps = iChildMapData.find(mapId); - if (childMaps != iChildMapData.end()) - for (uint32 childMapId : childMaps->second) - unloadSingleMap(childMapId); - - unloadSingleMap(mapId); - } - - void VMapManager2::unloadSingleMap(uint32 mapId) { auto instanceTree = iInstanceMapTrees.find(mapId); if (instanceTree != iInstanceMapTrees.end() && instanceTree->second) -- cgit v1.2.3