From dce92611f3ff33e7db0a7234d611f5bffb0cc45f Mon Sep 17 00:00:00 2001 From: leak Date: Sun, 20 Jul 2014 00:39:43 +0200 Subject: Refactored singletons to enable proper deconstruction during shutdown --- src/server/authserver/Main.cpp | 4 ++-- src/server/authserver/Realms/RealmList.h | 6 +++--- src/server/authserver/Server/AuthSession.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/server/authserver') diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp index 701f65c0c14..0f200db6af4 100644 --- a/src/server/authserver/Main.cpp +++ b/src/server/authserver/Main.cpp @@ -99,9 +99,9 @@ int main(int argc, char** argv) return 1; // Get the list of realms for the server - sRealmList.Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20)); + sRealmList->Initialize(_ioService, sConfigMgr->GetIntDefault("RealmsStateUpdateDelay", 20)); - if (sRealmList.size() == 0) + 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 b1c77d5a4b5..64419351b57 100644 --- a/src/server/authserver/Realms/RealmList.h +++ b/src/server/authserver/Realms/RealmList.h @@ -62,10 +62,10 @@ class RealmList public: typedef std::map RealmMap; - static RealmList& instance() + static RealmList* instance() { - static RealmList *instance = new RealmList(); - return *instance; + static RealmList instance; + return &instance; } ~RealmList(); diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp index f518dc7593b..987d6dca03f 100644 --- a/src/server/authserver/Server/AuthSession.cpp +++ b/src/server/authserver/Server/AuthSession.cpp @@ -797,13 +797,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 -- cgit v1.2.3