refactor(Core/Collision): Store collision data on map context (#25049)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "DisableMgr.h"
|
||||
#include "GridTerrainLoader.h"
|
||||
#include "MMapFactory.h"
|
||||
#include "IVMapMgr.h"
|
||||
#include "Map.h"
|
||||
#include "MMapMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "VMapFactory.h"
|
||||
@@ -9,6 +9,7 @@
|
||||
void GridTerrainLoader::LoadTerrain()
|
||||
{
|
||||
LoadMap();
|
||||
|
||||
if (_map->GetInstanceId() == 0)
|
||||
{
|
||||
LoadVMap();
|
||||
@@ -18,13 +19,10 @@ void GridTerrainLoader::LoadTerrain()
|
||||
|
||||
void GridTerrainLoader::LoadMap()
|
||||
{
|
||||
// Instances will point to the parent maps terrain data
|
||||
// Instances will point to the parent maps terrain data, no need to load anything.
|
||||
if (_map->GetInstanceId() != 0)
|
||||
{
|
||||
// load grid map for base map
|
||||
Map* parentMap = const_cast<Map*>(_map->GetParent());
|
||||
|
||||
// GetGridTerrainData will create the parent map grid
|
||||
_grid.SetTerrainData(parentMap->GetGridTerrainDataSharedPtr(GridCoord(_grid.GetX(), _grid.GetY())));
|
||||
return;
|
||||
}
|
||||
@@ -51,7 +49,7 @@ void GridTerrainLoader::LoadMap()
|
||||
|
||||
void GridTerrainLoader::LoadVMap()
|
||||
{
|
||||
int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapMgr()->loadMap((sWorld->GetDataPath() + "vmaps").c_str(), _map->GetId(), _grid.GetX(), _grid.GetY());
|
||||
int const vmapLoadResult = _map->GetMapCollisionData().LoadVMapTile(_grid.GetX(), _grid.GetY());
|
||||
switch (vmapLoadResult)
|
||||
{
|
||||
case VMAP::VMAP_LOAD_RESULT_OK:
|
||||
@@ -66,15 +64,14 @@ void GridTerrainLoader::LoadVMap()
|
||||
LOG_DEBUG("maps", "Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})",
|
||||
_map->GetMapName(), _map->GetId(), _grid.GetX(), _grid.GetY(), _grid.GetX(), _grid.GetY());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void GridTerrainLoader::LoadMMap()
|
||||
{
|
||||
if (!DisableMgr::IsPathfindingEnabled(_map))
|
||||
return;
|
||||
|
||||
int mmapLoadResult = MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(_map->GetId(), _grid.GetX(), _grid.GetY());
|
||||
int const mmapLoadResult = _map->GetMapCollisionData().LoadMMapTile(_grid.GetX(), _grid.GetY());
|
||||
switch (mmapLoadResult)
|
||||
{
|
||||
case MMAP::MMAP_LOAD_RESULT_OK:
|
||||
@@ -89,6 +86,8 @@ void GridTerrainLoader::LoadMMap()
|
||||
LOG_DEBUG("maps", "Ignored MMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})",
|
||||
_map->GetMapName(), _map->GetId(), _grid.GetX(), _grid.GetY(), _grid.GetX(), _grid.GetY());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,13 +144,3 @@ bool GridTerrainLoader::ExistVMap(uint32 mapid, int gx, int gy)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GridTerrainUnloader::UnloadTerrain()
|
||||
{
|
||||
// Only parent maps manage terrain data
|
||||
if (_map->GetInstanceId() != 0)
|
||||
return;
|
||||
|
||||
VMAP::VMapFactory::createOrGetVMapMgr()->unloadMap(_map->GetId(), _grid.GetX(), _grid.GetY());
|
||||
MMAP::MMapFactory::createOrGetMMapMgr()->unloadMap(_map->GetId(), _grid.GetX(), _grid.GetY());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user