feat(Core/Misc): remove and replace ACE_Singleton (#2418)

This commit is contained in:
Kargatum
2019-12-21 00:29:29 +07:00
committed by GitHub
parent 16b45bf334
commit 4a8f1de538
88 changed files with 486 additions and 250 deletions

View File

@@ -6,7 +6,6 @@
#ifndef ACORE_CREATUREAIFACTORY_H
#define ACORE_CREATUREAIFACTORY_H
//#include "Policies/Singleton.h"
#include "ObjectRegistry.h"
#include "FactoryHolder.h"
#include "GameObjectAI.h"
@@ -36,7 +35,6 @@ CreatureAIFactory<REAL_AI>::Create(void* data) const
typedef FactoryHolder<CreatureAI> CreatureAICreator;
typedef FactoryHolder<CreatureAI>::FactoryHolderRegistry CreatureAIRegistry;
typedef FactoryHolder<CreatureAI>::FactoryHolderRepository CreatureAIRepository;
//GO
struct SelectableGameObjectAI : public FactoryHolder<GameObjectAI>, public Permissible<GameObject>
@@ -64,5 +62,5 @@ GameObjectAIFactory<REAL_GO_AI>::Create(void* data) const
typedef FactoryHolder<GameObjectAI> GameObjectAICreator;
typedef FactoryHolder<GameObjectAI>::FactoryHolderRegistry GameObjectAIRegistry;
typedef FactoryHolder<GameObjectAI>::FactoryHolderRepository GameObjectAIRepository;
#endif

View File

@@ -19,7 +19,7 @@ namespace FactorySelector
CreatureAI* selectAI(Creature* creature)
{
const CreatureAICreator* ai_factory = NULL;
CreatureAIRegistry& ai_registry(*CreatureAIRepository::instance());
CreatureAIRegistry& ai_registry(*CreatureAIRegistry::instance());
// xinef: if we have controlable guardian, define petai for players as they can steer him, otherwise db / normal ai
// xinef: dont remember why i changed this qq commented out as may break some quests
@@ -92,7 +92,7 @@ namespace FactorySelector
MovementGenerator* selectMovementGenerator(Creature* creature)
{
MovementGeneratorRegistry& mv_registry(*MovementGeneratorRepository::instance());
MovementGeneratorRegistry& mv_registry(*MovementGeneratorRegistry::instance());
ASSERT(creature->GetCreatureTemplate());
const MovementGeneratorCreator* mv_factory = mv_registry.GetRegistryItem(creature->GetDefaultMovementType());
@@ -122,7 +122,7 @@ namespace FactorySelector
GameObjectAI* SelectGameObjectAI(GameObject* go)
{
const GameObjectAICreator* ai_factory = NULL;
GameObjectAIRegistry& ai_registry(*GameObjectAIRepository::instance());
GameObjectAIRegistry& ai_registry(*GameObjectAIRegistry::instance());
if (GameObjectAI* scriptedAI = sScriptMgr->GetGameObjectAI(go))
return scriptedAI;

View File

@@ -20,6 +20,12 @@
#include "SmartScriptMgr.h"
SmartWaypointMgr* SmartWaypointMgr::instance()
{
static SmartWaypointMgr instance;
return &instance;
}
void SmartWaypointMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
@@ -92,6 +98,12 @@ SmartWaypointMgr::~SmartWaypointMgr()
}
}
SmartAIMgr* SmartAIMgr::instance()
{
static SmartAIMgr instance;
return &instance;
}
void SmartAIMgr::LoadSmartAIFromDB()
{
uint32 oldMSTime = getMSTime();

View File

@@ -1569,6 +1569,7 @@ typedef std::unordered_map<uint32, WayPoint*> WPPath;
typedef std::list<WorldObject*> ObjectList;
typedef std::list<uint64> GuidList;
class ObjectGuidList
{
ObjectList* m_objectList;
@@ -1619,15 +1620,17 @@ public:
delete m_guidList;
}
};
typedef std::unordered_map<uint32, ObjectGuidList*> ObjectListMap;
class SmartWaypointMgr
{
friend class ACE_Singleton<SmartWaypointMgr, ACE_Null_Mutex>;
SmartWaypointMgr() {}
public:
~SmartWaypointMgr();
static SmartWaypointMgr* instance();
void LoadFromDB();
WPPath* GetPath(uint32 id)
@@ -1650,11 +1653,12 @@ typedef std::unordered_map<int32, SmartAIEventList> SmartAIEventMap;
class SmartAIMgr
{
friend class ACE_Singleton<SmartAIMgr, ACE_Null_Mutex>;
SmartAIMgr(){};
public:
~SmartAIMgr(){};
static SmartAIMgr* instance();
void LoadSmartAIFromDB();
SmartAIEventList GetScript(int32 entry, SmartScriptType type)
@@ -1812,6 +1816,7 @@ class SmartAIMgr
//bool IsTextValid(SmartScriptHolder const& e, uint32 id);
};
#define sSmartScriptMgr ACE_Singleton<SmartAIMgr, ACE_Null_Mutex>::instance()
#define sSmartWaypointMgr ACE_Singleton<SmartWaypointMgr, ACE_Null_Mutex>::instance()
#define sSmartScriptMgr SmartAIMgr::instance()
#define sSmartWaypointMgr SmartWaypointMgr::instance()
#endif