diff --git a/src/realmd/AuthSocket.cpp b/src/realmd/AuthSocket.cpp index bac584888..64e615254 100644 --- a/src/realmd/AuthSocket.cpp +++ b/src/realmd/AuthSocket.cpp @@ -32,8 +32,6 @@ #include "Auth/Sha1.h" //#include "Util.h" -- for commented utf8ToUpperOnlyLatin -extern RealmList m_realmList; - extern DatabaseType loginDatabase; #define ChunkSize 2048 @@ -881,14 +879,14 @@ bool AuthSocket::_HandleRealmList() delete result; ///- Update realm list if need - m_realmList.UpdateIfNeed(); + RealmList::Instance().UpdateIfNeed(); ///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm) ByteBuffer pkt; pkt << (uint32) 0; - pkt << (uint16) m_realmList.size(); + pkt << (uint16) RealmList::Instance().size(); RealmList::RealmMap::const_iterator i; - for( i = m_realmList.begin(); i != m_realmList.end(); ++i ) + for( i = RealmList::Instance().begin(); i != RealmList::Instance().end(); ++i ) { uint8 AmountOfCharacters; diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index 13fdc5747..2cfe62abd 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -55,7 +55,6 @@ void UnhookSignals(); void HookSignals(); bool stopEvent = false; ///< Setting it to true stops the server -RealmList m_realmList; ///< Holds the list of realms for this server DatabaseType loginDatabase; ///< Accessor to the realm server database @@ -191,8 +190,8 @@ extern int main(int argc, char **argv) return 1; ///- Get the list of realms for the server - m_realmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); - if (m_realmList.size() == 0) + RealmList::Instance().Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20)); + if (RealmList::Instance().size() == 0) { sLog.outError("No valid realms specified."); return 1; diff --git a/src/realmd/RealmList.cpp b/src/realmd/RealmList.cpp index 1bb0a977d..f41344c00 100644 --- a/src/realmd/RealmList.cpp +++ b/src/realmd/RealmList.cpp @@ -33,6 +33,12 @@ RealmList::RealmList( ) : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)) { } +RealmList& RealmList::Instance() +{ + static RealmList realmlist; + return realmlist; +} + /// Load the realm list from the database void RealmList::Initialize(uint32 updateInterval) { diff --git a/src/realmd/RealmList.h b/src/realmd/RealmList.h index 40e3956e8..1ab6d9371 100644 --- a/src/realmd/RealmList.h +++ b/src/realmd/RealmList.h @@ -43,6 +43,8 @@ class RealmList public: typedef std::map RealmMap; + static RealmList& Instance(); + RealmList(); ~RealmList() {} @@ -61,5 +63,6 @@ class RealmList uint32 m_UpdateInterval; time_t m_NextUpdateTime; }; + #endif /// @}