From 055acc4b8a7d903f450c5ba325f42b845a2b157f Mon Sep 17 00:00:00 2001 From: Chaz Brown Date: Sat, 29 Aug 2009 08:51:24 -0400 Subject: [PATCH] Replace switch with more proper way of checking allowSecurityLevel, and a few other minor changes. --HG-- branch : trunk --- src/game/World.cpp | 40 +++++++--------------------------------- src/game/World.h | 2 ++ src/game/WorldSocket.cpp | 3 ++- 3 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/game/World.cpp b/src/game/World.cpp index 0d80b9033f..db791f06bc 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -2509,46 +2509,20 @@ void World::ResetDailyQuests() itr->second->GetPlayer()->ResetDailyQuestStatus(); } -void World::SetPlayerLimit( int32 limit, bool needUpdate ) +void World::UpdateAllowedSecurity() { - //if(limit < -SEC_ADMINISTRATOR) - //limit = -SEC_ADMINISTRATOR; - - // lock update need - //bool db_update_need = needUpdate || (limit < 0) != (m_playerLimit < 0) || (limit < 0 && m_playerLimit < 0 && limit != m_playerLimit); - - m_playerLimit = limit; QueryResult *result = loginDatabase.PQuery("SELECT allowedSecurityLevel from realmlist WHERE id = '%d'", realmID); if (result) { - switch (result->Fetch()->GetUInt8()) - { - case SEC_ADMINISTRATOR: - { - m_allowedSecurityLevel = SEC_ADMINISTRATOR; - } - case SEC_MODERATOR: - { - m_allowedSecurityLevel = SEC_MODERATOR; - } - case SEC_GAMEMASTER: - { - m_allowedSecurityLevel = SEC_GAMEMASTER; - } - case SEC_PLAYER: - { - m_allowedSecurityLevel = SEC_PLAYER; - } - default: - { - m_allowedSecurityLevel = SEC_ADMINISTRATOR; - } - } + m_allowedSecurityLevel = AccountTypes(result->Fetch()->GetUInt16()); + sLog.outDebug("Allowed Level: %u Result %u", m_allowedSecurityLevel, result->Fetch()->GetUInt16()); delete result; } +} - //if(db_update_need) - //loginDatabase.PExecute("UPDATE realmlist SET allowedSecurityLevel = '%u' WHERE id = '%d'",uint8(GetPlayerSecurityLimit()),realmID); +void World::SetPlayerLimit( int32 limit, bool needUpdate ) +{ + m_playerLimit = limit; } void World::UpdateMaxSessionCounters() diff --git a/src/game/World.h b/src/game/World.h index 8c2692fa4d..e82546261f 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -592,6 +592,8 @@ class World void UpdateRealmCharCount(uint32 accid); + void UpdateAllowedSecurity(); + LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if(m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } //used World DB version diff --git a/src/game/WorldSocket.cpp b/src/game/WorldSocket.cpp index 0425085ea9..0da9c875ba 100644 --- a/src/game/WorldSocket.cpp +++ b/src/game/WorldSocket.cpp @@ -862,8 +862,9 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) } // Check locked state for server + sWorld.UpdateAllowedSecurity(); AccountTypes allowedAccountType = sWorld.GetPlayerSecurityLimit (); - + sLog.outDebug("Allowed Level: %u Player Level %u", allowedAccountType, AccountTypes(security)); if (allowedAccountType > SEC_PLAYER && AccountTypes(security) < allowedAccountType) { WorldPacket Packet (SMSG_AUTH_RESPONSE, 1);