aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/collision/Management/MMapFactory.cpp8
-rw-r--r--src/server/collision/Management/VMapManager2.cpp16
-rw-r--r--src/server/collision/Management/VMapManager2.h17
-rw-r--r--src/server/game/Conditions/DisableMgr.cpp29
-rw-r--r--src/server/game/Conditions/DisableMgr.h11
-rw-r--r--src/server/game/Maps/Map.cpp3
-rw-r--r--src/server/game/Movement/PathGenerator.cpp4
-rw-r--r--src/server/game/World/World.cpp7
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp3
-rw-r--r--src/server/scripts/Commands/cs_mmaps.cpp3
-rw-r--r--src/tools/mmaps_generator/MapBuilder.cpp8
-rw-r--r--src/tools/mmaps_generator/PathCommon.h2
12 files changed, 64 insertions, 47 deletions
diff --git a/src/server/collision/Management/MMapFactory.cpp b/src/server/collision/Management/MMapFactory.cpp
index b08cd92d638..51f016f6e96 100644
--- a/src/server/collision/Management/MMapFactory.cpp
+++ b/src/server/collision/Management/MMapFactory.cpp
@@ -17,9 +17,7 @@
*/
#include "MMapFactory.h"
-#include "World.h"
#include "Config.h"
-#include "DisableMgr.h"
namespace MMAP
{
@@ -35,12 +33,6 @@ namespace MMAP
return g_MMapManager;
}
- bool MMapFactory::IsPathfindingEnabled(uint32 mapId)
- {
- return sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS)
- && !DisableMgr::IsDisabledFor(DISABLE_TYPE_MMAP, mapId, NULL, MMAP_DISABLE_PATHFINDING);
- }
-
void MMapFactory::clear()
{
if (g_MMapManager)
diff --git a/src/server/collision/Management/VMapManager2.cpp b/src/server/collision/Management/VMapManager2.cpp
index 484fdcd8ea4..18d7a3849bb 100644
--- a/src/server/collision/Management/VMapManager2.cpp
+++ b/src/server/collision/Management/VMapManager2.cpp
@@ -25,8 +25,6 @@
#include "ModelInstance.h"
#include "WorldModel.h"
#include <G3D/Vector3.h>
-#include "DisableMgr.h"
-#include "DBCStores.h"
#include "Log.h"
#include "VMapDefinitions.h"
@@ -36,6 +34,8 @@ namespace VMAP
{
VMapManager2::VMapManager2()
{
+ GetLiquidFlagsPtr = &GetLiquidFlagsDummy;
+ IsVMAPDisabledForPtr = &IsVMAPDisabledForDummy;
}
VMapManager2::~VMapManager2(void)
@@ -134,7 +134,7 @@ namespace VMAP
bool VMapManager2::isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2)
{
- if (!isLineOfSightCalcEnabled() || DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
+ if (!isLineOfSightCalcEnabled() || IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LOS))
return true;
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
@@ -157,7 +157,7 @@ namespace VMAP
*/
bool VMapManager2::getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist)
{
- if (isLineOfSightCalcEnabled() && !DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
+ if (isLineOfSightCalcEnabled() && !IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LOS))
{
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
@@ -187,7 +187,7 @@ namespace VMAP
float VMapManager2::getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist)
{
- if (isHeightCalcEnabled() && !DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_HEIGHT))
+ if (isHeightCalcEnabled() && !IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_HEIGHT))
{
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
@@ -206,7 +206,7 @@ namespace VMAP
bool VMapManager2::getAreaInfo(unsigned int mapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
{
- if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_AREAFLAG))
+ if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_AREAFLAG))
{
InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
@@ -224,7 +224,7 @@ namespace VMAP
bool VMapManager2::GetLiquidLevel(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const
{
- if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LIQUIDSTATUS))
+ if (!IsVMAPDisabledForPtr(mapId, VMAP_DISABLE_LIQUIDSTATUS))
{
InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(mapId);
if (instanceTree != iInstanceMapTrees.end())
@@ -236,7 +236,7 @@ namespace VMAP
floor = info.ground_Z;
ASSERT(floor < std::numeric_limits<float>::max());
type = info.hitModel->GetLiquidType(); // entry from LiquidType.dbc
- if (reqLiquidType && !(GetLiquidFlags(type) & reqLiquidType))
+ if (reqLiquidType && !(GetLiquidFlagsPtr(type) & reqLiquidType))
return false;
if (info.hitInstance->GetLiquidLevel(pos, info, level))
return true;
diff --git a/src/server/collision/Management/VMapManager2.h b/src/server/collision/Management/VMapManager2.h
index 04292e7d8e4..9c419270b5a 100644
--- a/src/server/collision/Management/VMapManager2.h
+++ b/src/server/collision/Management/VMapManager2.h
@@ -66,6 +66,14 @@ namespace VMAP
typedef std::unordered_map<uint32, StaticMapTree*> InstanceTreeMap;
typedef std::unordered_map<std::string, ManagedModel> ModelFileMap;
+ enum DisableTypes
+ {
+ VMAP_DISABLE_AREAFLAG = 0x1,
+ VMAP_DISABLE_HEIGHT = 0x2,
+ VMAP_DISABLE_LOS = 0x4,
+ VMAP_DISABLE_LIQUIDSTATUS = 0x8
+ };
+
class VMapManager2 : public IVMapManager
{
protected:
@@ -78,6 +86,9 @@ namespace VMAP
bool _loadMap(uint32 mapId, const std::string& basePath, uint32 tileX, uint32 tileY);
/* void _unloadMap(uint32 pMapId, uint32 x, uint32 y); */
+ static uint32 GetLiquidFlagsDummy(uint32) { return 0; }
+ static bool IsVMAPDisabledForDummy(uint32 /*entry*/, uint8 /*flags*/) { return false; }
+
public:
// public for debug
G3D::Vector3 convertPositionToInternalRep(float x, float y, float z) const;
@@ -114,6 +125,12 @@ namespace VMAP
virtual bool existsMap(const char* basePath, unsigned int mapId, int x, int y) override;
public:
void getInstanceMapTree(InstanceTreeMap &instanceMapTree);
+
+ typedef uint32(*GetLiquidFlagsFn)(uint32 liquidType);
+ GetLiquidFlagsFn GetLiquidFlagsPtr;
+
+ typedef bool(*IsVMAPDisabledForFn)(uint32 entry, uint8 flags);
+ IsVMAPDisabledForFn IsVMAPDisabledForPtr;
};
}
diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp
index 3f325be1e83..eb50545b510 100644
--- a/src/server/game/Conditions/DisableMgr.cpp
+++ b/src/server/game/Conditions/DisableMgr.cpp
@@ -21,8 +21,8 @@
#include "ObjectMgr.h"
#include "OutdoorPvP.h"
#include "SpellMgr.h"
-#include "VMapManager2.h"
#include "Player.h"
+#include "World.h"
namespace DisableMgr
{
@@ -193,28 +193,28 @@ void LoadDisables()
switch (mapEntry->map_type)
{
case MAP_COMMON:
- if (flags & VMAP_DISABLE_AREAFLAG)
+ if (flags & VMAP::VMAP_DISABLE_AREAFLAG)
TC_LOG_INFO("misc", "Areaflag disabled for world map %u.", entry);
- if (flags & VMAP_DISABLE_LIQUIDSTATUS)
+ if (flags & VMAP::VMAP_DISABLE_LIQUIDSTATUS)
TC_LOG_INFO("misc", "Liquid status disabled for world map %u.", entry);
break;
case MAP_INSTANCE:
case MAP_RAID:
- if (flags & VMAP_DISABLE_HEIGHT)
+ if (flags & VMAP::VMAP_DISABLE_HEIGHT)
TC_LOG_INFO("misc", "Height disabled for instance map %u.", entry);
- if (flags & VMAP_DISABLE_LOS)
+ if (flags & VMAP::VMAP_DISABLE_LOS)
TC_LOG_INFO("misc", "LoS disabled for instance map %u.", entry);
break;
case MAP_BATTLEGROUND:
- if (flags & VMAP_DISABLE_HEIGHT)
+ if (flags & VMAP::VMAP_DISABLE_HEIGHT)
TC_LOG_INFO("misc", "Height disabled for battleground map %u.", entry);
- if (flags & VMAP_DISABLE_LOS)
+ if (flags & VMAP::VMAP_DISABLE_LOS)
TC_LOG_INFO("misc", "LoS disabled for battleground map %u.", entry);
break;
case MAP_ARENA:
- if (flags & VMAP_DISABLE_HEIGHT)
+ if (flags & VMAP::VMAP_DISABLE_HEIGHT)
TC_LOG_INFO("misc", "Height disabled for arena map %u.", entry);
- if (flags & VMAP_DISABLE_LOS)
+ if (flags & VMAP::VMAP_DISABLE_LOS)
TC_LOG_INFO("misc", "LoS disabled for arena map %u.", entry);
break;
default:
@@ -387,4 +387,15 @@ bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags
return false;
}
+bool IsVMAPDisabledFor(uint32 entry, uint8 flags)
+{
+ return IsDisabledFor(DISABLE_TYPE_VMAP, entry, NULL, flags);
+}
+
+bool IsPathfindingEnabled(uint32 mapId)
+{
+ return sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS)
+ && !IsDisabledFor(DISABLE_TYPE_MMAP, mapId, NULL, MMAP_DISABLE_PATHFINDING);
+}
+
} // Namespace
diff --git a/src/server/game/Conditions/DisableMgr.h b/src/server/game/Conditions/DisableMgr.h
index 0930da78547..f6c65abe90a 100644
--- a/src/server/game/Conditions/DisableMgr.h
+++ b/src/server/game/Conditions/DisableMgr.h
@@ -19,6 +19,7 @@
#ifndef TRINITY_DISABLEMGR_H
#define TRINITY_DISABLEMGR_H
+#include "VMapManager2.h"
#include "Define.h"
class Unit;
@@ -49,14 +50,6 @@ enum SpellDisableTypes
SPELL_DISABLE_LOS)
};
-enum VmapDisableTypes
-{
- VMAP_DISABLE_AREAFLAG = 0x1,
- VMAP_DISABLE_HEIGHT = 0x2,
- VMAP_DISABLE_LOS = 0x4,
- VMAP_DISABLE_LIQUIDSTATUS = 0x8
-};
-
enum MMapDisableTypes
{
MMAP_DISABLE_PATHFINDING = 0x0
@@ -67,6 +60,8 @@ namespace DisableMgr
void LoadDisables();
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags = 0);
void CheckQuestDisables();
+ bool IsVMAPDisabledFor(uint32 entry, uint8 flags);
+ bool IsPathfindingEnabled(uint32 mapId);
}
#endif //TRINITY_DISABLEMGR_H
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index ca8771dd0bb..37563acd74a 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -20,6 +20,7 @@
#include "Battleground.h"
#include "MMapFactory.h"
#include "CellImpl.h"
+#include "DisableMgr.h"
#include "DynamicTree.h"
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
@@ -119,7 +120,7 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy)
void Map::LoadMMap(int gx, int gy)
{
- if (!MMAP::MMapFactory::IsPathfindingEnabled(GetId()))
+ if (!DisableMgr::IsPathfindingEnabled(GetId()))
return;
bool mmapLoadResult = MMAP::MMapFactory::createOrGetMMapManager()->loadMap((sWorld->GetDataPath() + "mmaps").c_str(), GetId(), gx, gy);
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp
index cbf88b68028..afd1f73c785 100644
--- a/src/server/game/Movement/PathGenerator.cpp
+++ b/src/server/game/Movement/PathGenerator.cpp
@@ -22,7 +22,7 @@
#include "MMapFactory.h"
#include "MMapManager.h"
#include "Log.h"
-
+#include "DisableMgr.h"
#include "DetourCommon.h"
#include "DetourNavMeshQuery.h"
@@ -38,7 +38,7 @@ PathGenerator::PathGenerator(const Unit* owner) :
TC_LOG_DEBUG("maps", "++ PathGenerator::PathGenerator for %u \n", _sourceUnit->GetGUIDLow());
uint32 mapId = _sourceUnit->GetMapId();
- if (MMAP::MMapFactory::IsPathfindingEnabled(mapId))
+ if (DisableMgr::IsPathfindingEnabled(mapId))
{
MMAP::MMapManager* mmap = MMAP::MMapFactory::createOrGetMMapManager();
_navMesh = mmap->GetNavMesh(mapId);
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 903e14f7506..fae613797e9 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1283,6 +1283,13 @@ void World::SetInitialWorldSettings()
///- Initialize detour memory management
dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
+ ///- Initialize VMapManager function pointers (to untangle game/collision circular deps)
+ if (VMAP::VMapManager2* vmmgr2 = dynamic_cast<VMAP::VMapManager2*>(VMAP::VMapFactory::createOrGetVMapManager()))
+ {
+ vmmgr2->GetLiquidFlagsPtr = &GetLiquidFlags;
+ vmmgr2->IsVMAPDisabledForPtr = &DisableMgr::IsVMAPDisabledFor;
+ }
+
///- Initialize config settings
LoadConfigSettings();
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index b4b9928d6f8..a7716d3230b 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -35,6 +35,7 @@
#include "LFG.h"
#include "GroupMgr.h"
#include "MMapFactory.h"
+#include "DisableMgr.h"
class misc_commandscript : public CommandScript
{
@@ -186,7 +187,7 @@ public:
uint32 haveMap = Map::ExistMap(mapId, gridX, gridY) ? 1 : 0;
uint32 haveVMap = Map::ExistVMap(mapId, gridX, gridY) ? 1 : 0;
- uint32 haveMMap = (MMAP::MMapFactory::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0;
+ uint32 haveMMap = (DisableMgr::IsPathfindingEnabled(mapId) && MMAP::MMapFactory::createOrGetMMapManager()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId())) ? 1 : 0;
if (haveVMap)
{
diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp
index 0be5994e8ed..bba14eb8332 100644
--- a/src/server/scripts/Commands/cs_mmaps.cpp
+++ b/src/server/scripts/Commands/cs_mmaps.cpp
@@ -25,6 +25,7 @@
#include "ScriptMgr.h"
#include "Chat.h"
+#include "DisableMgr.h"
#include "ObjectMgr.h"
#include "Player.h"
#include "PointMovementGenerator.h"
@@ -209,7 +210,7 @@ public:
{
uint32 mapId = handler->GetSession()->GetPlayer()->GetMapId();
handler->PSendSysMessage("mmap stats:");
- handler->PSendSysMessage(" global mmap pathfinding is %sabled", MMAP::MMapFactory::IsPathfindingEnabled(mapId) ? "en" : "dis");
+ handler->PSendSysMessage(" global mmap pathfinding is %sabled", DisableMgr::IsPathfindingEnabled(mapId) ? "en" : "dis");
MMAP::MMapManager* manager = MMAP::MMapFactory::createOrGetMMapManager();
handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount());
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp
index 885dd24d760..2f8b35fd52d 100644
--- a/src/tools/mmaps_generator/MapBuilder.cpp
+++ b/src/tools/mmaps_generator/MapBuilder.cpp
@@ -27,14 +27,6 @@
#include "DetourNavMesh.h"
#include "DetourCommon.h"
-#include "DisableMgr.h"
-
-uint32 GetLiquidFlags(uint32 /*liquidType*/) { return 0; }
-namespace DisableMgr
-{
- bool IsDisabledFor(DisableType /*type*/, uint32 /*entry*/, Unit const* /*unit*/, uint8 /*flags*/ /*= 0*/) { return false; }
-}
-
#define MMAP_MAGIC 0x4d4d4150 // 'MMAP'
#define MMAP_VERSION 5
diff --git a/src/tools/mmaps_generator/PathCommon.h b/src/tools/mmaps_generator/PathCommon.h
index 8285fef74f2..694e40dacde 100644
--- a/src/tools/mmaps_generator/PathCommon.h
+++ b/src/tools/mmaps_generator/PathCommon.h
@@ -62,7 +62,7 @@ namespace MMAP
if (*++filter == '\0') // wildcard at end of filter means all remaing chars match
return true;
- while (true)
+ for (;;)
{
if (*filter == *str)
break;