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

@@ -35,6 +35,12 @@ ObjectAccessor::~ObjectAccessor()
{
}
ObjectAccessor* ObjectAccessor::instance()
{
static ObjectAccessor instance;
return &instance;
}
Player* ObjectAccessor::GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/)
{
Player* player = HashMapHolder<Player>::Find(guid);

View File

@@ -11,7 +11,6 @@
#include "UpdateData.h"
#include "GridDefines.h"
#include "Object.h"
#include <ace/Singleton.h>
#include <ace/Thread_Mutex.h>
#include <unordered_map>
#include <set>
@@ -87,7 +86,6 @@ public:
class ObjectAccessor
{
friend class ACE_Singleton<ObjectAccessor, ACE_Null_Mutex>;
private:
ObjectAccessor();
~ObjectAccessor();
@@ -95,6 +93,7 @@ class ObjectAccessor
ObjectAccessor& operator=(const ObjectAccessor&);
public:
static ObjectAccessor* instance();
// TODO: override these template functions for each holder type and add assertions
template<class T> static T* GetObjectInOrOutOfWorld(uint64 guid, T* /*typeSpecifier*/)
@@ -277,5 +276,6 @@ class ObjectAccessor
mutable ACE_Thread_Mutex DelayedCorpseLock;
};
#define sObjectAccessor ACE_Singleton<ObjectAccessor, ACE_Null_Mutex>::instance()
#define sObjectAccessor ObjectAccessor::instance()
#endif

View File

@@ -270,6 +270,12 @@ ObjectMgr::~ObjectMgr()
delete itr->second;
}
ObjectMgr* ObjectMgr::instance()
{
static ObjectMgr instance;
return &instance;
}
void ObjectMgr::AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data)
{
if (!s.empty())

View File

@@ -23,7 +23,6 @@
#include "Map.h"
#include "ObjectAccessor.h"
#include "ObjectDefines.h"
#include <ace/Singleton.h>
#include "VehicleDefines.h"
#include <string>
#include <map>
@@ -465,12 +464,14 @@ typedef std::unordered_map<uint32, BroadcastText> BroadcastTextContainer;
typedef std::set<uint32> CellGuidSet;
typedef std::unordered_map<uint32/*player guid*/, uint32/*instance*/> CellCorpseSet;
struct CellObjectGuids
{
CellGuidSet creatures;
CellGuidSet gameobjects;
CellCorpseSet corpses;
};
typedef std::unordered_map<uint32/*cell_id*/, CellObjectGuids> CellObjectGuidsMap;
typedef std::unordered_map<uint32/*(mapid, spawnMode) pair*/, CellObjectGuidsMap> MapObjectGuids;
@@ -686,13 +687,14 @@ class PlayerDumpReader;
class ObjectMgr
{
friend class PlayerDumpReader;
friend class ACE_Singleton<ObjectMgr, ACE_Null_Mutex>;
private:
ObjectMgr();
~ObjectMgr();
public:
static ObjectMgr* instance();
typedef std::unordered_map<uint32, Item*> ItemMap;
typedef std::unordered_map<uint32, Quest*> QuestMap;
@@ -1499,6 +1501,6 @@ class ObjectMgr
std::set<uint32> _transportMaps; // Helper container storing map ids that are for transports only, loaded from gameobject_template
};
#define sObjectMgr ACE_Singleton<ObjectMgr, ACE_Null_Mutex>::instance()
#define sObjectMgr ObjectMgr::instance()
#endif