Replace switch with more proper way of checking allowSecurityLevel, and a few other minor changes.

--HG--
branch : trunk
This commit is contained in:
Chaz Brown
2009-08-29 08:51:24 -04:00
parent 2345c5ca8d
commit 055acc4b8a
3 changed files with 11 additions and 34 deletions
+7 -33
View File
@@ -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()
+2
View File
@@ -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
+2 -1
View File
@@ -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);