mirror of
https://github.com/mangosfour/server.git
synced 2025-12-17 07:37:03 +00:00
Make RealmList proper singleton in realmd.
This commit is contained in:
parent
1f23884757
commit
6abf7e7f58
4 changed files with 14 additions and 8 deletions
|
|
@ -32,8 +32,6 @@
|
||||||
#include "Auth/Sha1.h"
|
#include "Auth/Sha1.h"
|
||||||
//#include "Util.h" -- for commented utf8ToUpperOnlyLatin
|
//#include "Util.h" -- for commented utf8ToUpperOnlyLatin
|
||||||
|
|
||||||
extern RealmList m_realmList;
|
|
||||||
|
|
||||||
extern DatabaseType loginDatabase;
|
extern DatabaseType loginDatabase;
|
||||||
|
|
||||||
#define ChunkSize 2048
|
#define ChunkSize 2048
|
||||||
|
|
@ -881,14 +879,14 @@ bool AuthSocket::_HandleRealmList()
|
||||||
delete result;
|
delete result;
|
||||||
|
|
||||||
///- Update realm list if need
|
///- 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)
|
///- Circle through realms in the RealmList and construct the return packet (including # of user characters in each realm)
|
||||||
ByteBuffer pkt;
|
ByteBuffer pkt;
|
||||||
pkt << (uint32) 0;
|
pkt << (uint32) 0;
|
||||||
pkt << (uint16) m_realmList.size();
|
pkt << (uint16) RealmList::Instance().size();
|
||||||
RealmList::RealmMap::const_iterator i;
|
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;
|
uint8 AmountOfCharacters;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,6 @@ void UnhookSignals();
|
||||||
void HookSignals();
|
void HookSignals();
|
||||||
|
|
||||||
bool stopEvent = false; ///< Setting it to true stops the server
|
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
|
DatabaseType loginDatabase; ///< Accessor to the realm server database
|
||||||
|
|
||||||
|
|
@ -191,8 +190,8 @@ extern int main(int argc, char **argv)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
///- Get the list of realms for the server
|
///- Get the list of realms for the server
|
||||||
m_realmList.Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20));
|
RealmList::Instance().Initialize(sConfig.GetIntDefault("RealmsStateUpdateDelay", 20));
|
||||||
if (m_realmList.size() == 0)
|
if (RealmList::Instance().size() == 0)
|
||||||
{
|
{
|
||||||
sLog.outError("No valid realms specified.");
|
sLog.outError("No valid realms specified.");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -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
|
/// Load the realm list from the database
|
||||||
void RealmList::Initialize(uint32 updateInterval)
|
void RealmList::Initialize(uint32 updateInterval)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,8 @@ class RealmList
|
||||||
public:
|
public:
|
||||||
typedef std::map<std::string, Realm> RealmMap;
|
typedef std::map<std::string, Realm> RealmMap;
|
||||||
|
|
||||||
|
static RealmList& Instance();
|
||||||
|
|
||||||
RealmList();
|
RealmList();
|
||||||
~RealmList() {}
|
~RealmList() {}
|
||||||
|
|
||||||
|
|
@ -61,5 +63,6 @@ class RealmList
|
||||||
uint32 m_UpdateInterval;
|
uint32 m_UpdateInterval;
|
||||||
time_t m_NextUpdateTime;
|
time_t m_NextUpdateTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue