diff options
author | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 15:35:07 -0700 |
commit | 26b5e033ffde3d161382fc9addbfa99738379641 (patch) | |
tree | a344f369ca32945f787a02dee35c3dbe342bed7e /src/trinityrealm/RealmList.cpp | |
parent | f21f47005dcb6b76e1abc9f35fbcd03eed191bff (diff) |
*Massive cleanup (\n\n -> \n, *\n -> \n, cleanup for(...) to for (...), and some other cleanups by hand)
*Fix a possible crash in Spell::DoAllEffectOnTarget
--HG--
branch : trunk
Diffstat (limited to 'src/trinityrealm/RealmList.cpp')
-rw-r--r-- | src/trinityrealm/RealmList.cpp | 19 |
1 files changed, 0 insertions, 19 deletions
diff --git a/src/trinityrealm/RealmList.cpp b/src/trinityrealm/RealmList.cpp index be8a7738ef7..c4b78bfe482 100644 --- a/src/trinityrealm/RealmList.cpp +++ b/src/trinityrealm/RealmList.cpp @@ -17,38 +17,29 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ - /** \file \ingroup realmd */ - #include "Common.h" #include "RealmList.h" #include "Policies/SingletonImp.h" #include "Database/DatabaseEnv.h" - INSTANTIATE_SINGLETON_1(RealmList); - extern DatabaseType loginDatabase; - RealmList::RealmList() : m_UpdateInterval(0), m_NextUpdateTime(time(NULL)) { } - /// Load the realm list from the database void RealmList::Initialize(uint32 updateInterval) { m_UpdateInterval = updateInterval; - ///- Get the content of the realmlist table in the database UpdateRealms(true); } - void RealmList::UpdateRealm(uint32 ID, const std::string& name, const std::string& address, uint32 port, uint8 icon, uint8 color, uint8 timezone, AccountTypes allowedSecurityLevel, float popu, uint32 build) { ///- Create new if not exist or update existed Realm& realm = m_realms[name]; - realm.m_ID = ID; realm.name = name; realm.icon = icon; @@ -56,44 +47,34 @@ void RealmList::UpdateRealm(uint32 ID, const std::string& name, const std::strin realm.timezone = timezone; realm.allowedSecurityLevel = allowedSecurityLevel; realm.populationLevel = popu; - ///- Append port to IP address. std::ostringstream ss; ss << address << ":" << port; realm.address = ss.str(); realm.gamebuild = build; } - void RealmList::UpdateIfNeed() { // maybe disabled or updated recently if (!m_UpdateInterval || m_NextUpdateTime > time(NULL)) return; - m_NextUpdateTime = time(NULL) + m_UpdateInterval; - // Clears Realm list m_realms.clear(); - // Get the content of the realmlist table in the database UpdateRealms(false); } - void RealmList::UpdateRealms(bool init) { sLog.outDetail("Updating Realm List..."); - QueryResult *result = loginDatabase.Query("SELECT id, name, address, port, icon, color, timezone, allowedSecurityLevel, population, gamebuild FROM realmlist WHERE color <> 3 ORDER BY name"); - ///- Circle through results and add them to the realm map if (result) { do { Field *fields = result->Fetch(); - uint8 allowedSecurityLevel = fields[7].GetUInt8(); - UpdateRealm(fields[0].GetUInt32(), fields[1].GetCppString(),fields[2].GetCppString(),fields[3].GetUInt32(),fields[4].GetUInt8(), fields[5].GetUInt8(), fields[6].GetUInt8(), (allowedSecurityLevel <= SEC_ADMINISTRATOR ? AccountTypes(allowedSecurityLevel) : SEC_ADMINISTRATOR), fields[8].GetFloat(), fields[9].GetUInt32()); if (init) sLog.outString("Added realm \"%s\".", fields[1].GetString()); |