Core/MMaps: Remove phased tile support

* Extremely slow
* Needs to be implemented partially in tools
* Conflicts with upcoming phasing rewrite
This commit is contained in:
Aokromes
2018-03-06 00:22:05 +01:00
parent 523a2dccdc
commit c33ff02c34
9 changed files with 54 additions and 358 deletions

View File

@@ -23,11 +23,11 @@ namespace MMAP
{
// ######################## MMapFactory ########################
// our global singleton copy
MMapManager* g_MMapManager = NULL;
MMapManager* g_MMapManager = nullptr;
MMapManager* MMapFactory::createOrGetMMapManager()
{
if (g_MMapManager == NULL)
if (g_MMapManager == nullptr)
g_MMapManager = new MMapManager();
return g_MMapManager;
@@ -38,7 +38,7 @@ namespace MMAP
if (g_MMapManager)
{
delete g_MMapManager;
g_MMapManager = NULL;
g_MMapManager = nullptr;
}
}
}

View File

@@ -37,19 +37,11 @@ namespace MMAP
// if we had, tiles in MMapData->mmapLoadedTiles, their actual data is lost!
}
void MMapManager::InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData)
void MMapManager::InitializeThreadUnsafe(const std::vector<uint32>& mapIds)
{
// the caller must pass the list of all mapIds that will be used in the MMapManager lifetime
for (auto const& p : mapData)
{
loadedMMaps.insert(MMapDataSet::value_type(p.first, nullptr));
if (!p.second.empty())
{
phaseMapData[p.first] = p.second;
for (uint32 phasedMapId : p.second)
_phaseTiles.insert(PhaseTileMap::value_type(phasedMapId, PhaseTileContainer()));
}
}
// the caller must pass the list of all mapIds that will be used in the VMapManager2 lifetime
for (uint32 const& mapId : mapIds)
loadedMMaps.insert(MMapDataSet::value_type(mapId, nullptr));
thread_safe_environment = false;
}
@@ -111,7 +103,7 @@ namespace MMAP
TC_LOG_DEBUG("maps", "MMAP:loadMapData: Loaded %03i.mmap", mapId);
// store inside our map list
MMapData* mmap_data = new MMapData(mesh, mapId);
MMapData* mmap_data = new MMapData(mesh);
itr->second = mmap_data;
return true;
@@ -191,111 +183,18 @@ namespace MMAP
dtTileRef tileRef = 0;
// memory allocated for data is now managed by detour, and will be deallocated when the tile is removed
if (dtStatusSucceed(mmap->navMesh->addTile(data, fileHeader.size, 0/*DT_TILE_FREE_DATA*/, 0, &tileRef)))
if (dtStatusSucceed(mmap->navMesh->addTile(data, fileHeader.size, DT_TILE_FREE_DATA, 0, &tileRef)))
{
mmap->loadedTileRefs.insert(std::pair<uint32, dtTileRef>(packedGridPos, tileRef));
++loadedTiles;
TC_LOG_DEBUG("maps", "MMAP:loadMap: Loaded mmtile %03i[%02i, %02i] into %03i[%02i, %02i]", mapId, x, y, mapId, header->x, header->y);
PhaseChildMapContainer::const_iterator phasedMaps = phaseMapData.find(mapId);
if (phasedMaps != phaseMapData.end())
LoadPhaseTiles(phasedMaps, x, y);
return true;
}
TC_LOG_ERROR("maps", "MMAP:loadMap: Could not load %03u%02i%02i.mmtile into navmesh", mapId, x, y);
dtFree(data);
return false;
}
PhasedTile* MMapManager::LoadTile(uint32 mapId, int32 x, int32 y)
{
// load this tile :: mmaps/MMMXXYY.mmtile
std::string fileName = Trinity::StringFormat(TILE_FILE_NAME_FORMAT, sConfigMgr->GetStringDefault("DataDir", ".").c_str(), mapId, x, y);
FILE* file = fopen(fileName.c_str(), "rb");
if (!file)
else
{
// Not all tiles have phased versions, don't flood this msg
//TC_LOG_DEBUG("phase", "MMAP:LoadTile: Could not open mmtile file '%s'", fileName);
return NULL;
}
PhasedTile* pTile = new PhasedTile();
// read header
if (fread(&pTile->fileHeader, sizeof(MmapTileHeader), 1, file) != 1 || pTile->fileHeader.mmapMagic != MMAP_MAGIC)
{
TC_LOG_ERROR("phase", "MMAP:LoadTile: Bad header in mmap %03u%02i%02i.mmtile", mapId, x, y);
fclose(file);
delete pTile;
return nullptr;
}
if (pTile->fileHeader.mmapVersion != MMAP_VERSION)
{
TC_LOG_ERROR("phase", "MMAP:LoadTile: %03u%02i%02i.mmtile was built with generator v%i, expected v%i",
mapId, x, y, pTile->fileHeader.mmapVersion, MMAP_VERSION);
fclose(file);
delete pTile;
return nullptr;
}
pTile->data = (unsigned char*)dtAlloc(pTile->fileHeader.size, DT_ALLOC_PERM);
ASSERT(pTile->data);
size_t result = fread(pTile->data, pTile->fileHeader.size, 1, file);
if (!result)
{
TC_LOG_ERROR("phase", "MMAP:LoadTile: Bad header or data in mmap %03u%02i%02i.mmtile", mapId, x, y);
fclose(file);
delete pTile;
return nullptr;
}
fclose(file);
return pTile;
}
void MMapManager::LoadPhaseTiles(PhaseChildMapContainer::const_iterator phasedMapData, int32 x, int32 y)
{
TC_LOG_DEBUG("phase", "MMAP:LoadPhaseTiles: Loading phased mmtiles for map %u, x: %i, y: %i", phasedMapData->first, x, y);
uint32 packedGridPos = packTileID(x, y);
for (uint32 phaseMapId : phasedMapData->second)
{
// only a few tiles have terrain swaps, do not write error for them
if (PhasedTile* data = LoadTile(phaseMapId, x, y))
{
TC_LOG_DEBUG("phase", "MMAP:LoadPhaseTiles: Loaded phased %03u%02i%02i.mmtile for root phase map %u", phaseMapId, x, y, phasedMapData->first);
_phaseTiles[phaseMapId][packedGridPos] = data;
}
}
}
void MMapManager::UnloadPhaseTile(PhaseChildMapContainer::const_iterator phasedMapData, int32 x, int32 y)
{
TC_LOG_DEBUG("phase", "MMAP:UnloadPhaseTile: Unloading phased mmtile for map %u, x: %i, y: %i", phasedMapData->first, x, y);
uint32 packedGridPos = packTileID(x, y);
for (uint32 phaseMapId : phasedMapData->second)
{
auto phasedTileItr = _phaseTiles.find(phaseMapId);
if (phasedTileItr == _phaseTiles.end())
continue;
auto dataItr = phasedTileItr->second.find(packedGridPos);
if (dataItr != phasedTileItr->second.end())
{
TC_LOG_DEBUG("phase", "MMAP:UnloadPhaseTile: Unloaded phased %04u%02i%02i.mmtile for root phase map %u", phaseMapId, x, y, phasedMapData->first);
delete dataItr->second->data;
delete dataItr->second;
phasedTileItr->second.erase(dataItr);
}
TC_LOG_ERROR("maps", "MMAP:loadMap: Could not load %04u%02i%02i.mmtile into navmesh", mapId, x, y);
dtFree(data);
return false;
}
}
@@ -324,7 +223,7 @@ namespace MMAP
dtTileRef tileRef = mmap->loadedTileRefs[packedGridPos];
// unload, and mark as non loaded
if (dtStatusFailed(mmap->navMesh->removeTile(tileRef, NULL, NULL)))
if (dtStatusFailed(mmap->navMesh->removeTile(tileRef, nullptr, nullptr)))
{
// this is technically a memory leak
// if the grid is later reloaded, dtNavMesh::addTile will return error but no extra memory is used
@@ -336,11 +235,7 @@ namespace MMAP
{
mmap->loadedTileRefs.erase(packedGridPos);
--loadedTiles;
TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
PhaseChildMapContainer::const_iterator phasedMaps = phaseMapData.find(mapId);
if (phasedMaps != phaseMapData.end())
UnloadPhaseTile(phasedMaps, x, y);
TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %04i[%02i, %02i] from %03i", mapId, x, y, mapId);
return true;
}
@@ -363,13 +258,10 @@ namespace MMAP
{
uint32 x = (i->first >> 16);
uint32 y = (i->first & 0x0000FFFF);
if (dtStatusFailed(mmap->navMesh->removeTile(i->second, NULL, NULL)))
if (dtStatusFailed(mmap->navMesh->removeTile(i->second, nullptr, nullptr)))
TC_LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
else
{
PhaseChildMapContainer::const_iterator phasedMaps = phaseMapData.find(mapId);
if (phasedMaps != phaseMapData.end())
UnloadPhaseTile(phasedMaps, x, y);
--loadedTiles;
TC_LOG_DEBUG("maps", "MMAP:unloadMap: Unloaded mmtile %03i[%02i, %02i] from %03i", mapId, x, y, mapId);
}
@@ -409,20 +301,20 @@ namespace MMAP
return true;
}
dtNavMesh const* MMapManager::GetNavMesh(uint32 mapId, TerrainSet swaps)
dtNavMesh const* MMapManager::GetNavMesh(uint32 mapId)
{
MMapDataSet::const_iterator itr = GetMMapData(mapId);
if (itr == loadedMMaps.end())
return NULL;
return nullptr;
return itr->second->GetNavMesh(swaps);
return itr->second->navMesh;
}
dtNavMeshQuery const* MMapManager::GetNavMeshQuery(uint32 mapId, uint32 instanceId, TerrainSet swaps)
dtNavMeshQuery const* MMapManager::GetNavMeshQuery(uint32 mapId, uint32 instanceId)
{
MMapDataSet::const_iterator itr = GetMMapData(mapId);
if (itr == loadedMMaps.end())
return NULL;
return nullptr;
MMapData* mmap = itr->second;
if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
@@ -430,11 +322,11 @@ namespace MMAP
// allocate mesh query
dtNavMeshQuery* query = dtAllocNavMeshQuery();
ASSERT(query);
if (dtStatusFailed(query->init(mmap->GetNavMesh(swaps), 1024)))
if (dtStatusFailed(query->init(mmap->navMesh, 1024)))
{
dtFreeNavMeshQuery(query);
TC_LOG_ERROR("maps", "MMAP:GetNavMeshQuery: Failed to initialize dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
return NULL;
return nullptr;
}
TC_LOG_DEBUG("maps", "MMAP:GetNavMeshQuery: created dtNavMeshQuery for mapId %03u instanceId %u", mapId, instanceId);
@@ -443,150 +335,4 @@ namespace MMAP
return mmap->navMeshQueries[instanceId];
}
MMapData::MMapData(dtNavMesh* mesh, uint32 mapId)
{
navMesh = mesh;
_mapId = mapId;
}
MMapData::~MMapData()
{
for (NavMeshQuerySet::iterator i = navMeshQueries.begin(); i != navMeshQueries.end(); ++i)
dtFreeNavMeshQuery(i->second);
dtFreeNavMesh(navMesh);
for (PhaseTileContainer::iterator i = _baseTiles.begin(); i != _baseTiles.end(); ++i)
{
delete (*i).second->data;
delete (*i).second;
}
}
void MMapData::RemoveSwap(PhasedTile* ptile, uint32 swap, uint32 packedXY)
{
uint32 x = (packedXY >> 16);
uint32 y = (packedXY & 0x0000FFFF);
if (loadedPhasedTiles[swap].find(packedXY) == loadedPhasedTiles[swap].end())
{
TC_LOG_DEBUG("phase", "MMapData::RemoveSwap: mmtile %03u[%02i, %02i] unload skipped, due to not loaded", swap, x, y);
return;
}
dtMeshHeader* header = (dtMeshHeader*)ptile->data;
// remove old tile
if (dtStatusFailed(navMesh->removeTile(loadedTileRefs[packedXY], NULL, NULL)))
TC_LOG_ERROR("phase", "MMapData::RemoveSwap: Could not unload phased %03u%02i%02i.mmtile from navmesh", swap, x, y);
else
{
TC_LOG_DEBUG("phase", "MMapData::RemoveSwap: Unloaded phased %03u%02i%02i.mmtile from navmesh", swap, x, y);
// restore base tile
if (dtStatusSucceed(navMesh->addTile(_baseTiles[packedXY]->data, _baseTiles[packedXY]->dataSize, 0, 0, &loadedTileRefs[packedXY])))
{
TC_LOG_DEBUG("phase", "MMapData::RemoveSwap: Loaded base mmtile %03u[%02i, %02i] into %03i[%02i, %02i]", _mapId, x, y, _mapId, header->x, header->y);
}
else
TC_LOG_ERROR("phase", "MMapData::RemoveSwap: Could not load base %03u%02i%02i.mmtile to navmesh", _mapId, x, y);
}
loadedPhasedTiles[swap].erase(packedXY);
if (loadedPhasedTiles[swap].empty())
{
_activeSwaps.erase(swap);
TC_LOG_DEBUG("phase", "MMapData::RemoveSwap: Fully removed swap %u from map %u", swap, _mapId);
}
}
void MMapData::AddSwap(PhasedTile* ptile, uint32 swap, uint32 packedXY)
{
uint32 x = (packedXY >> 16);
uint32 y = (packedXY & 0x0000FFFF);
if (loadedTileRefs.find(packedXY) == loadedTileRefs.end())
{
TC_LOG_DEBUG("phase", "MMapData::AddSwap: phased mmtile %03u[%02i, %02i] load skipped, due to not loaded base tile on map %u", swap, x, y, _mapId);
return;
}
if (loadedPhasedTiles[swap].find(packedXY) != loadedPhasedTiles[swap].end())
{
TC_LOG_DEBUG("phase", "MMapData::AddSwap: WARNING! phased mmtile %03u[%02i, %02i] load skipped, due to already loaded on map %u", swap, x, y, _mapId);
return;
}
dtMeshHeader* header = (dtMeshHeader*)ptile->data;
const dtMeshTile* oldTile = navMesh->getTileByRef(loadedTileRefs[packedXY]);
if (!oldTile)
{
TC_LOG_DEBUG("phase", "MMapData::AddSwap: phased mmtile %03u[%02i, %02i] load skipped, due to not loaded base tile ref on map %u", swap, x, y, _mapId);
return;
}
// header xy is based on the swap map's tile set, wich doesn't have all the same tiles as root map, so copy the xy from the orignal header
header->x = oldTile->header->x;
header->y = oldTile->header->y;
// the removed tile's data
PhasedTile* pt = new PhasedTile();
// remove old tile
if (dtStatusFailed(navMesh->removeTile(loadedTileRefs[packedXY], &pt->data, &pt->dataSize)))
{
TC_LOG_ERROR("phase", "MMapData::AddSwap: Could not unload %03u%02i%02i.mmtile from navmesh", _mapId, x, y);
delete pt;
}
else
{
TC_LOG_DEBUG("phase", "MMapData::AddSwap: Unloaded %03u%02i%02i.mmtile from navmesh", _mapId, x, y);
// store the removed data first time, this is the origonal, non-phased tile
if (_baseTiles.find(packedXY) == _baseTiles.end())
_baseTiles[packedXY] = pt;
_activeSwaps.insert(swap);
loadedPhasedTiles[swap].insert(packedXY);
// add new swapped tile
if (dtStatusSucceed(navMesh->addTile(ptile->data, ptile->fileHeader.size, 0, 0, &loadedTileRefs[packedXY])))
{
TC_LOG_DEBUG("phase", "MMapData::AddSwap: Loaded phased mmtile %03u[%02i, %02i] into %03i[%02i, %02i]", swap, x, y, _mapId, header->x, header->y);
}
else
TC_LOG_ERROR("phase", "MMapData::AddSwap: Could not load %03u%02i%02i.mmtile to navmesh", swap, x, y);
}
}
dtNavMesh* MMapData::GetNavMesh(TerrainSet swaps)
{
std::set<uint32> activeSwaps = _activeSwaps; // _activeSwaps is modified inside RemoveSwap
for (uint32 swap : activeSwaps)
{
if (!swaps.count(swap)) // swap not active
{
if (PhaseTileContainer const* ptc = MMAP::MMapFactory::createOrGetMMapManager()->GetPhaseTileContainer(swap))
for (PhaseTileContainer::const_iterator itr = ptc->begin(); itr != ptc->end(); ++itr)
RemoveSwap(itr->second, swap, itr->first); // remove swap
}
}
// for each of the calling unit's terrain swaps
for (uint32 swap : swaps)
{
if (!_activeSwaps.count(swap)) // swap not active
{
// for each of the terrain swap's xy tiles
if (PhaseTileContainer const* ptc = MMAP::MMapFactory::createOrGetMMapManager()->GetPhaseTileContainer(swap))
for (PhaseTileContainer::const_iterator itr = ptc->begin(); itr != ptc->end(); ++itr)
AddSwap(itr->second, swap, itr->first); // add swap
}
}
return navMesh;
}
}

View File

@@ -22,10 +22,8 @@
#include "Define.h"
#include "DetourNavMesh.h"
#include "DetourNavMeshQuery.h"
#include "MapDefines.h"
#include <string>
#include <unordered_map>
#include <set>
#include <vector>
// move map related classes
@@ -34,54 +32,25 @@ namespace MMAP
typedef std::unordered_map<uint32, dtTileRef> MMapTileSet;
typedef std::unordered_map<uint32, dtNavMeshQuery*> NavMeshQuerySet;
typedef std::set<uint32> TerrainSet;
struct NavMeshHolder
// dummy struct to hold map's mmap data
struct TC_COMMON_API MMapData
{
// Pre-built navMesh
dtNavMesh* navMesh;
MMapData(dtNavMesh* mesh) : navMesh(mesh) { }
~MMapData()
{
for (NavMeshQuerySet::iterator i = navMeshQueries.begin(); i != navMeshQueries.end(); ++i)
dtFreeNavMeshQuery(i->second);
// List of terrain swap map ids used to build the navMesh
TerrainSet terrainIds;
MMapTileSet loadedTileRefs;
};
struct PhasedTile
{
unsigned char* data;
MmapTileHeader fileHeader;
int32 dataSize;
};
typedef std::unordered_map<uint32, PhasedTile*> PhaseTileContainer;
typedef std::unordered_map<uint32, PhaseTileContainer> PhaseTileMap;
typedef std::unordered_map<uint32, TerrainSet> TerrainSetMap;
class TC_COMMON_API MMapData
{
public:
MMapData(dtNavMesh* mesh, uint32 mapId);
~MMapData();
dtNavMesh* GetNavMesh(TerrainSet swaps);
if (navMesh)
dtFreeNavMesh(navMesh);
}
// we have to use single dtNavMeshQuery for every instance, since those are not thread safe
NavMeshQuerySet navMeshQueries; // instanceId to query
dtNavMesh* navMesh;
MMapTileSet loadedTileRefs;
TerrainSetMap loadedPhasedTiles;
private:
uint32 _mapId;
PhaseTileContainer _baseTiles;
std::set<uint32> _activeSwaps;
void RemoveSwap(PhasedTile* ptile, uint32 swap, uint32 packedXY);
void AddSwap(PhasedTile* tile, uint32 swap, uint32 packedXY);
MMapTileSet loadedTileRefs; // maps [map grid coords] to [dtTile]
};
@@ -95,41 +64,26 @@ namespace MMAP
MMapManager() : loadedTiles(0), thread_safe_environment(true) {}
~MMapManager();
void InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData);
void InitializeThreadUnsafe(const std::vector<uint32>& mapIds);
bool loadMap(const std::string& basePath, uint32 mapId, int32 x, int32 y);
bool unloadMap(uint32 mapId, int32 x, int32 y);
bool unloadMap(uint32 mapId);
bool unloadMapInstance(uint32 mapId, uint32 instanceId);
// the returned [dtNavMeshQuery const*] is NOT threadsafe
dtNavMeshQuery const* GetNavMeshQuery(uint32 mapId, uint32 instanceId, TerrainSet swaps);
dtNavMesh const* GetNavMesh(uint32 mapId, TerrainSet swaps);
dtNavMeshQuery const* GetNavMeshQuery(uint32 mapId, uint32 instanceId);
dtNavMesh const* GetNavMesh(uint32 mapId);
uint32 getLoadedTilesCount() const { return loadedTiles; }
uint32 getLoadedMapsCount() const { return uint32(loadedMMaps.size()); }
typedef std::unordered_map<uint32, std::vector<uint32>> PhaseChildMapContainer;
void LoadPhaseTiles(PhaseChildMapContainer::const_iterator phasedMapData, int32 x, int32 y);
void UnloadPhaseTile(PhaseChildMapContainer::const_iterator phasedMapData, int32 x, int32 y);
PhaseTileContainer const* GetPhaseTileContainer(uint32 mapId) const
{
auto itr = _phaseTiles.find(mapId);
if (itr != _phaseTiles.end())
return &itr->second;
return nullptr;
}
private:
bool loadMapData(uint32 mapId);
uint32 packTileID(int32 x, int32 y);
MMapDataSet::const_iterator GetMMapData(uint32 mapId) const;
MMapDataSet loadedMMaps;
PhaseChildMapContainer phaseMapData;
uint32 loadedTiles;
bool thread_safe_environment;
PhasedTile* LoadTile(uint32 mapId, int32 x, int32 y);
PhaseTileMap _phaseTiles;
};
}

View File

@@ -52,11 +52,11 @@ namespace VMAP
}
}
void VMapManager2::InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData)
void VMapManager2::InitializeThreadUnsafe(const std::vector<uint32>& mapIds)
{
// the caller must pass the list of all mapIds that will be used in the VMapManager2 lifetime
for (auto const& p : mapData)
iInstanceMapTrees.insert(InstanceTreeMap::value_type(p.first, nullptr));
for (uint32 const& mapId : mapIds)
iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, nullptr));
thread_safe_environment = false;
}

View File

@@ -101,7 +101,7 @@ namespace VMAP
VMapManager2();
~VMapManager2(void);
void InitializeThreadUnsafe(std::unordered_map<uint32, std::vector<uint32>> const& mapData);
void InitializeThreadUnsafe(const std::vector<uint32>& mapIds);
int loadMap(const char* pBasePath, unsigned int mapId, int x, int y) override;
void unloadMap(unsigned int mapId, int x, int y) override;

View File

@@ -43,8 +43,8 @@ PathGenerator::PathGenerator(const Unit* owner) :
if (DisableMgr::IsPathfindingEnabled(mapId))
{
MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager();
_navMesh = mmap->GetNavMesh(mapId, _sourceUnit->GetTerrainSwaps());
_navMeshQuery = mmap->GetNavMeshQuery(mapId, _sourceUnit->GetInstanceId(), _sourceUnit->GetTerrainSwaps());
_navMesh = mmap->GetNavMesh(mapId);
_navMeshQuery = mmap->GetNavMeshQuery(mapId, _sourceUnit->GetInstanceId());
}
CreateFilter();

View File

@@ -1502,19 +1502,15 @@ void World::SetInitialWorldSettings()
// Load M2 fly by cameras
LoadM2Cameras(m_dataPath);
std::unordered_map<uint32, std::vector<uint32>> mapData;
std::vector<uint32> mapIds;
for (MapEntry const* mapEntry : sMapStore)
{
mapData.insert(std::unordered_map<uint32, std::vector<uint32>>::value_type(mapEntry->MapID, std::vector<uint32>()));
if (mapEntry->rootPhaseMap != -1)
mapData[mapEntry->rootPhaseMap].push_back(mapEntry->MapID);
}
mapIds.push_back(mapEntry->ID);
if (VMAP::VMapManager2* vmmgr2 = dynamic_cast<VMAP::VMapManager2*>(VMAP::VMapFactory::createOrGetVMapManager()))
vmmgr2->InitializeThreadUnsafe(mapData);
vmmgr2->InitializeThreadUnsafe(mapIds);
MMAP::MMapManager* mmmgr = MMAP::MMapFactory::createOrGetMMapManager();
mmmgr->InitializeThreadUnsafe(mapData);
mmmgr->InitializeThreadUnsafe(mapIds);
TC_LOG_INFO("server.loading", "Initializing PlayerDump tables...");
PlayerDump::InitializeTables();

View File

@@ -248,7 +248,7 @@ public:
uint32 haveMap = Map::ExistMap(mapId, gridX, gridY) ? 1 : 0;
uint32 haveVMap = Map::ExistVMap(mapId, gridX, gridY) ? 1 : 0;
uint32 haveMMap = (DisableMgr::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId(), handler->GetSession()->GetPlayer()->GetTerrainSwaps())) ? 1 : 0;
uint32 haveMMap = (DisableMgr::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0;
if (haveVMap)
{

View File

@@ -62,7 +62,7 @@ public:
static bool HandleMmapPathCommand(ChatHandler* handler, char const* args)
{
if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId(), handler->GetSession()->GetPlayer()->GetTerrainSwaps()))
if (!MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()))
{
handler->PSendSysMessage("NavMesh not loaded for current map.");
return true;
@@ -134,8 +134,8 @@ public:
handler->PSendSysMessage("gridloc [%i, %i]", gy, gx);
// calculate navmesh tile location
dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId(), handler->GetSession()->GetPlayer()->GetTerrainSwaps());
dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(handler->GetSession()->GetPlayer()->GetMapId(), player->GetInstanceId(), handler->GetSession()->GetPlayer()->GetTerrainSwaps());
dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId());
dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(handler->GetSession()->GetPlayer()->GetMapId(), player->GetInstanceId());
if (!navmesh || !navmeshquery)
{
handler->PSendSysMessage("NavMesh not loaded for current map.");
@@ -186,8 +186,8 @@ public:
static bool HandleMmapLoadedTilesCommand(ChatHandler* handler, char const* /*args*/)
{
uint32 mapid = handler->GetSession()->GetPlayer()->GetMapId();
dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(mapid, handler->GetSession()->GetPlayer()->GetTerrainSwaps());
dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(mapid, handler->GetSession()->GetPlayer()->GetInstanceId(), handler->GetSession()->GetPlayer()->GetTerrainSwaps());
dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(mapid);
dtNavMeshQuery const* navmeshquery = MMAP::MMapFactory::createOrGetMMapManager()->GetNavMeshQuery(mapid, handler->GetSession()->GetPlayer()->GetInstanceId());
if (!navmesh || !navmeshquery)
{
handler->PSendSysMessage("NavMesh not loaded for current map.");
@@ -217,7 +217,7 @@ public:
MMAP::MMapManager* manager = MMAP::MMapFactory::createOrGetMMapManager();
handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount());
dtNavMesh const* navmesh = manager->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId(), handler->GetSession()->GetPlayer()->GetTerrainSwaps());
dtNavMesh const* navmesh = manager->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId());
if (!navmesh)
{
handler->PSendSysMessage("NavMesh not loaded for current map.");