diff options
author | Spp <none@none> | 2010-08-24 19:09:41 +0200 |
---|---|---|
committer | Spp <none@none> | 2010-08-24 19:09:41 +0200 |
commit | 89d87339d57b932f81bbddf8a57542d8cc3074fc (patch) | |
tree | 72dff8698d124b9bc71038410c3ae0d3c093857f | |
parent | 119e05781047ab9d0b7629a3d89c9b67cd78056c (diff) |
Core: Update Player Limit and Player Security Level variables
- Allowed Security Level will be set at server load or with 'server plimit reset' command (before it was read each time someone tried to join)
- If Security Level is updated to a more restrictive value all people under that level will be autokicked
--HG--
branch : trunk
-rw-r--r-- | src/server/game/Chat/Commands/Level3.cpp | 11 | ||||
-rw-r--r-- | src/server/game/Server/WorldSocket.cpp | 1 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 26 | ||||
-rw-r--r-- | src/server/game/World/World.h | 17 |
4 files changed, 28 insertions, 27 deletions
diff --git a/src/server/game/Chat/Commands/Level3.cpp b/src/server/game/Chat/Commands/Level3.cpp index 954d806d050..c1e46896d77 100644 --- a/src/server/game/Chat/Commands/Level3.cpp +++ b/src/server/game/Chat/Commands/Level3.cpp @@ -6228,19 +6228,18 @@ bool ChatHandler::HandleServerPLimitCommand(const char *args) else if (strncmp(param,"administrator",l) == 0) sWorld.SetPlayerSecurityLimit(SEC_ADMINISTRATOR); else if (strncmp(param,"reset",l) == 0) - sWorld.SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", 100)); + { + sWorld.SetPlayerAmountLimit(sConfig.GetIntDefault("PlayerLimit", 100)); + sWorld.LoadDBAllowedSecurityLevel(); + } else { int val = atoi(param); if (val < 0) sWorld.SetPlayerSecurityLimit(AccountTypes(uint32(-val))); else - sWorld.SetPlayerLimit(val); + sWorld.SetPlayerAmountLimit(uint32(val)); } - - // kick all low security level players - if (sWorld.GetPlayerSecurityLimit() > SEC_PLAYER) - sWorld.KickAllLess(sWorld.GetPlayerSecurityLimit()); } uint32 pLimit = sWorld.GetPlayerAmountLimit(); diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp index 6eb5dff67f9..667473aa3f4 100644 --- a/src/server/game/Server/WorldSocket.cpp +++ b/src/server/game/Server/WorldSocket.cpp @@ -930,7 +930,6 @@ 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) diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 5453391df46..0927794122b 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -419,7 +419,7 @@ void World::LoadConfigSettings(bool reload) } ///- Read the player limit and the Message of the day from the config file - SetPlayerLimit(sConfig.GetIntDefault("PlayerLimit", 100), true); + SetPlayerAmountLimit(sConfig.GetIntDefault("PlayerLimit", 100)); SetMotd(sConfig.GetStringDefault("Motd", "Welcome to a Trinity Core Server.")); ///- Get string for new logins (newly created characters) @@ -1226,6 +1226,9 @@ void World::SetInitialWorldSettings() ///- Initialize config settings LoadConfigSettings(); + + ///- Initialize Allowed Security Level + LoadDBAllowedSecurityLevel(); ///- Init highest guids before any table loading to prevent using not initialized guids in some code. sObjectMgr.SetHighestGuids(); @@ -2569,14 +2572,20 @@ void World::ResetDailyQuests() itr->second->GetPlayer()->ResetDailyQuestStatus(); } -void World::UpdateAllowedSecurity() +void World::LoadDBAllowedSecurityLevel() { QueryResult_AutoPtr result = LoginDatabase.PQuery("SELECT allowedSecurityLevel from realmlist WHERE id = '%d'", realmID); if (result) - { - m_allowedSecurityLevel = AccountTypes(result->Fetch()->GetUInt16()); - sLog.outDebug("Allowed Level: %u Result %u", m_allowedSecurityLevel, result->Fetch()->GetUInt16()); - } + SetPlayerSecurityLimit(AccountTypes(result->Fetch()->GetUInt16())); +} + +void World::SetPlayerSecurityLimit(AccountTypes _sec) +{ + AccountTypes sec = _sec < SEC_CONSOLE ? _sec : SEC_PLAYER; + bool update = sec > m_allowedSecurityLevel; + m_allowedSecurityLevel = sec; + if (update) + KickAllLess(m_allowedSecurityLevel); } void World::ResetWeeklyQuests() @@ -2602,11 +2611,6 @@ void World::ResetRandomBG() sWorld.setWorldState(WS_BG_DAILY_RESET_TIME, uint64(m_NextRandomBGReset)); } -void World::SetPlayerLimit(int32 limit, bool /*needUpdate*/) -{ - m_playerLimit = limit; -} - void World::UpdateMaxSessionCounters() { m_maxActiveSessionCount = std::max(m_maxActiveSessionCount,uint32(m_sessions.size()-m_QueuedPlayer.size())); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 8ee4f5b4643..d3c4ab5d32e 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -544,13 +544,14 @@ class World /// Close world void SetClosed(bool val); - /// Get the active session server limit (or security level limitations) - uint32 GetPlayerAmountLimit() const { return m_playerLimit >= 0 ? m_playerLimit : 0; } - AccountTypes GetPlayerSecurityLimit() const { return m_allowedSecurityLevel < 0 ? SEC_PLAYER : m_allowedSecurityLevel; } - void SetPlayerSecurityLimit(AccountTypes sec) { m_allowedSecurityLevel = (sec < SEC_PLAYER ? SEC_PLAYER : sec); } + /// Security level limitations + AccountTypes GetPlayerSecurityLimit() const { return m_allowedSecurityLevel; } + void SetPlayerSecurityLimit(AccountTypes sec); + void LoadDBAllowedSecurityLevel(); - /// Set the active session server limit (or security level limitation) - void SetPlayerLimit(int32 limit, bool needUpdate = false); + /// Active session server limit + void SetPlayerAmountLimit(uint32 limit) { m_playerLimit = limit; } + uint32 GetPlayerAmountLimit() const { return m_playerLimit; } //player Queue typedef std::list<WorldSession*> Queue; @@ -710,8 +711,6 @@ 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 @@ -778,7 +777,7 @@ class World float m_float_configs[FLOAT_CONFIG_VALUE_COUNT]; typedef std::map<uint32,uint64> WorldStatesMap; WorldStatesMap m_worldstates; - int32 m_playerLimit; + uint32 m_playerLimit; AccountTypes m_allowedSecurityLevel; LocaleConstant m_defaultDbcLocale; // from config for one from loaded DBC locales uint32 m_availableDbcLocaleMask; // by loaded DBC |