mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 15:46:24 +00:00
refactor(Core/Misc): add braces and impove codestyle (#6402)
This commit is contained in:
@@ -18,7 +18,9 @@ namespace MMAP
|
||||
MMapManager* MMapFactory::createOrGetMMapManager()
|
||||
{
|
||||
if (g_MMapManager == nullptr)
|
||||
{
|
||||
g_MMapManager = new MMapManager();
|
||||
}
|
||||
|
||||
return g_MMapManager;
|
||||
}
|
||||
@@ -29,7 +31,9 @@ namespace MMAP
|
||||
int32 f[] = {616 /*EoE*/, 649 /*ToC25*/, 650 /*ToC5*/, -1};
|
||||
uint32 i = 0;
|
||||
while (f[i] >= 0)
|
||||
{
|
||||
forbiddenMaps[f[i++]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MMapFactory::clear()
|
||||
|
||||
@@ -20,7 +20,9 @@ namespace MMAP
|
||||
MMapManager::~MMapManager()
|
||||
{
|
||||
for (MMapDataSet::iterator i = loadedMMaps.begin(); i != loadedMMaps.end(); ++i)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
|
||||
// by now we should not have maps loaded
|
||||
// if we had, tiles in MMapData->mmapLoadedTiles, their actual data is lost!
|
||||
@@ -30,7 +32,9 @@ namespace MMAP
|
||||
{
|
||||
// the caller must pass the list of all mapIds that will be used in the VMapManager2 lifetime
|
||||
for (const uint32& mapId : mapIds)
|
||||
{
|
||||
loadedMMaps.emplace(mapId, nullptr);
|
||||
}
|
||||
|
||||
thread_safe_environment = false;
|
||||
}
|
||||
@@ -40,7 +44,9 @@ namespace MMAP
|
||||
// return the iterator if found or end() if not found/NULL
|
||||
MMapDataSet::const_iterator itr = loadedMMaps.find(mapId);
|
||||
if (itr != loadedMMaps.cend() && !itr->second)
|
||||
{
|
||||
itr = loadedMMaps.cend();
|
||||
}
|
||||
|
||||
return itr;
|
||||
}
|
||||
@@ -52,14 +58,20 @@ namespace MMAP
|
||||
if (itr != loadedMMaps.end())
|
||||
{
|
||||
if (itr->second)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (thread_safe_environment)
|
||||
{
|
||||
itr = loadedMMaps.insert(MMapDataSet::value_type(mapId, nullptr)).first;
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(false, "Invalid mapId %u passed to MMapManager after startup in thread unsafe environment", mapId);
|
||||
}
|
||||
}
|
||||
|
||||
// load and init dtNavMesh - read parameters from file
|
||||
@@ -107,7 +119,9 @@ namespace MMAP
|
||||
{
|
||||
// make sure the mmap is loaded and ready to load tiles
|
||||
if (!loadMapData(mapId))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// get this mmap data
|
||||
MMapData* mmap = loadedMMaps[mapId];
|
||||
@@ -243,7 +257,9 @@ namespace MMAP
|
||||
uint32 y = (i.first & 0x0000FFFF);
|
||||
|
||||
if (dtStatusFailed(mmap->navMesh->removeTile(i.second, nullptr, nullptr)))
|
||||
{
|
||||
LOG_ERROR("maps", "MMAP:unloadMap: Could not unload %03u%02i%02i.mmtile from navmesh", mapId, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
--loadedTiles;
|
||||
@@ -289,7 +305,9 @@ namespace MMAP
|
||||
{
|
||||
MMapDataSet::const_iterator itr = GetMMapData(mapId);
|
||||
if (itr == loadedMMaps.end())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return itr->second->navMesh;
|
||||
}
|
||||
@@ -298,7 +316,9 @@ namespace MMAP
|
||||
{
|
||||
MMapDataSet::const_iterator itr = GetMMapData(mapId);
|
||||
if (itr == loadedMMaps.end())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MMapData* mmap = itr->second;
|
||||
if (mmap->navMeshQueries.find(instanceId) == mmap->navMeshQueries.end())
|
||||
|
||||
@@ -40,10 +40,14 @@ namespace MMAP
|
||||
~MMapData()
|
||||
{
|
||||
for (NavMeshQuerySet::iterator i = navMeshQueries.begin(); i != navMeshQueries.end(); ++i)
|
||||
{
|
||||
dtFreeNavMeshQuery(i->second);
|
||||
}
|
||||
|
||||
if (navMesh)
|
||||
{
|
||||
dtFreeNavMesh(navMesh);
|
||||
}
|
||||
}
|
||||
|
||||
// we have to use single dtNavMeshQuery for every instance, since those are not thread safe
|
||||
|
||||
@@ -16,7 +16,9 @@ namespace VMAP
|
||||
VMapManager2* VMapFactory::createOrGetVMapManager()
|
||||
{
|
||||
if (!gVMapManager)
|
||||
{
|
||||
gVMapManager = new VMapManager2();
|
||||
}
|
||||
|
||||
return gVMapManager;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,9 @@ namespace VMAP
|
||||
{
|
||||
// the caller must pass the list of all mapIds that will be used in the VMapManager2 lifetime
|
||||
for (const uint32& mapId : mapIds)
|
||||
{
|
||||
iInstanceMapTrees.emplace(mapId, nullptr);
|
||||
}
|
||||
|
||||
thread_safe_environment = false;
|
||||
}
|
||||
@@ -78,7 +80,9 @@ namespace VMAP
|
||||
// return the iterator if found or end() if not found/NULL
|
||||
InstanceTreeMap::const_iterator itr = iInstanceMapTrees.find(mapId);
|
||||
if (itr != iInstanceMapTrees.cend() && !itr->second)
|
||||
{
|
||||
itr = iInstanceMapTrees.cend();
|
||||
}
|
||||
|
||||
return itr;
|
||||
}
|
||||
@@ -99,9 +103,13 @@ namespace VMAP
|
||||
if (isMapLoadingEnabled())
|
||||
{
|
||||
if (_loadMap(mapId, basePath, x, y))
|
||||
{
|
||||
result = VMAP_LOAD_RESULT_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = VMAP_LOAD_RESULT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -114,10 +122,12 @@ namespace VMAP
|
||||
if (instanceTree == iInstanceMapTrees.end())
|
||||
{
|
||||
if (thread_safe_environment)
|
||||
{
|
||||
instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(mapId, nullptr)).first;
|
||||
}
|
||||
else
|
||||
ASSERT(false, "Invalid mapId %u tile [%u, %u] passed to VMapManager2 after startup in thread unsafe environment",
|
||||
mapId, tileX, tileY);
|
||||
mapId, tileX, tileY);
|
||||
}
|
||||
|
||||
if (!instanceTree->second)
|
||||
@@ -167,7 +177,9 @@ namespace VMAP
|
||||
{
|
||||
#if defined(ENABLE_VMAP_CHECKS)
|
||||
if (!isLineOfSightCalcEnabled() || IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LOS))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
InstanceTreeMap::const_iterator instanceTree = GetMapTree(mapId);
|
||||
@@ -232,7 +244,9 @@ namespace VMAP
|
||||
Vector3 pos = convertPositionToInternalRep(x, y, z);
|
||||
float height = instanceTree->second->getHeight(pos, maxSearchDist);
|
||||
if (!(height < G3D::finf()))
|
||||
return height = VMAP_INVALID_HEIGHT_VALUE; // No height
|
||||
{
|
||||
return height = VMAP_INVALID_HEIGHT_VALUE; // No height
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
@@ -278,9 +292,13 @@ namespace VMAP
|
||||
ASSERT(floor < std::numeric_limits<float>::max());
|
||||
type = info.hitModel->GetLiquidType(); // entry from LiquidType.dbc
|
||||
if (reqLiquidType && !(GetLiquidFlagsPtr(type) & reqLiquidType))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (info.hitInstance->GetLiquidLevel(pos, info, level))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user