diff options
-rw-r--r-- | src/server/authserver/Main.cpp | 5 | ||||
-rw-r--r-- | src/server/authserver/Realms/RealmList.h | 16 | ||||
-rw-r--r-- | src/server/authserver/Server/AuthSession.cpp | 4 |
3 files changed, 15 insertions, 10 deletions
diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp index 27834f50814..2427c47a438 100644 --- a/src/server/authserver/Main.cpp +++ b/src/server/authserver/Main.cpp @@ -152,8 +152,9 @@ int main(int argc, char** argv) return 1; // Get the list of realms for the server - sRealmList->Initialize(sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20)); - if (sRealmList->size() == 0) + sRealmList.Initialize(sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20)); + + if (sRealmList.size() == 0) { TC_LOG_ERROR("server.authserver", "No valid realms specified."); return 1; diff --git a/src/server/authserver/Realms/RealmList.h b/src/server/authserver/Realms/RealmList.h index 88da30ea963..29b6aca07d3 100644 --- a/src/server/authserver/Realms/RealmList.h +++ b/src/server/authserver/Realms/RealmList.h @@ -19,8 +19,6 @@ #ifndef _REALMLIST_H #define _REALMLIST_H -#include <ace/Singleton.h> -#include <ace/Null_Mutex.h> #include <ace/INET_Addr.h> #include "Common.h" @@ -59,8 +57,11 @@ class RealmList public: typedef std::map<std::string, Realm> RealmMap; - RealmList(); - ~RealmList() { } + static RealmList& instance() + { + static RealmList *instance = new RealmList(); + return *instance; + } void Initialize(uint32 updateInterval); @@ -73,13 +74,16 @@ public: uint32 size() const { return m_realms.size(); } private: + RealmList(); + void UpdateRealms(bool init = false); - void UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask, uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build); + void UpdateRealm(uint32 id, const std::string& name, ACE_INET_Addr const& address, ACE_INET_Addr const& localAddr, ACE_INET_Addr const& localSubmask, + uint8 icon, RealmFlags flag, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build); RealmMap m_realms; uint32 m_UpdateInterval; time_t m_NextUpdateTime; }; -#define sRealmList ACE_Singleton<RealmList, ACE_Null_Mutex>::instance() +#define sRealmList RealmList::instance() #endif diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp index a366f7d11f7..627e1fc470d 100644 --- a/src/server/authserver/Server/AuthSession.cpp +++ b/src/server/authserver/Server/AuthSession.cpp @@ -772,13 +772,13 @@ bool AuthSession::_HandleRealmList() uint32 id = fields[0].GetUInt32(); // Update realm list if need - sRealmList->UpdateIfNeed(); + sRealmList.UpdateIfNeed(); // Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm) ByteBuffer pkt; size_t RealmListSize = 0; - for (RealmList::RealmMap::const_iterator i = sRealmList->begin(); i != sRealmList->end(); ++i) + for (RealmList::RealmMap::const_iterator i = sRealmList.begin(); i != sRealmList.end(); ++i) { const Realm &realm = i->second; // don't work with realms which not compatible with the client |