mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 10:26:28 +01:00
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
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user