Removed maxClients caching in core (bug 5007, bug 4986, r=fyren).

This commit is contained in:
Nicholas Hastings 2011-07-06 17:50:37 -04:00
parent 053b522aff
commit 5ba82ef0fc
2 changed files with 17 additions and 20 deletions

View File

@ -111,7 +111,6 @@ PlayerManager::PlayerManager()
{
m_AuthQueue = NULL;
m_FirstPass = false;
m_maxClients = 0;
m_UserIdLookUp = new int[USHRT_MAX+1];
memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
@ -232,12 +231,12 @@ ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
int maxClients = gpGlobals->maxClients;
if (!m_FirstPass)
{
/* Initialize all players */
// clientMax will not necessarily be correct here (such as on late SourceTV enable)
m_maxClients = gpGlobals->maxClients;
m_PlayerCount = 0;
m_Players = new CPlayer[ABSOLUTE_PLAYER_LIMIT + 1];
@ -248,9 +247,9 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
g_NumPlayersToAuth = &m_AuthQueue[0];
g_PluginSys.SyncMaxClients(clientMax);
g_PluginSys.SyncMaxClients(maxClients);
}
g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, clientMax);
g_Extensions.CallOnCoreMapStart(pEdictList, edictCount, maxClients);
m_onActivate->Execute(NULL);
m_onActivate2->Execute(NULL);
@ -259,7 +258,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
{
if ((*iter)->GetClientListenerVersion() >= 5)
{
(*iter)->OnServerActivated(clientMax);
(*iter)->OnServerActivated(maxClients);
}
}
@ -582,7 +581,8 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
void PlayerManager::OnSourceModLevelEnd()
{
/* Disconnect all bots still in game */
for (int i=1; i<=m_maxClients; i++)
int maxClients = gpGlobals->maxClients;
for (int i=1; i<=maxClients; i++)
{
if (m_Players[i].IsConnected())
{
@ -851,12 +851,12 @@ void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
int PlayerManager::GetMaxClients()
{
return m_maxClients;
return gpGlobals->maxClients;
}
CPlayer *PlayerManager::GetPlayerByIndex(int client) const
{
if (client > m_maxClients || client < 1)
if (client > gpGlobals->maxClients || client < 1)
{
return NULL;
}
@ -896,7 +896,8 @@ int PlayerManager::GetClientOfUserId(int userid)
/* If we can't verify the userid, we have to do a manual loop */
CPlayer *player;
for (int i = 1; i <= m_maxClients; i++)
int maxClients = gpGlobals->maxClients;
for (int i = 1; i <= maxClients; i++)
{
player = GetPlayerByIndex(i);
if (!player || !player->IsConnected())
@ -936,7 +937,8 @@ IGamePlayer *PlayerManager::GetGamePlayer(int client)
void PlayerManager::ClearAdminId(AdminId id)
{
for (int i=1; i<=m_maxClients; i++)
int maxClients = gpGlobals->maxClients;
for (int i=1; i<=maxClients; i++)
{
if (m_Players[i].m_Admin == id)
{
@ -947,7 +949,8 @@ void PlayerManager::ClearAdminId(AdminId id)
void PlayerManager::ClearAllAdmins()
{
for (int i=1; i<=m_maxClients; i++)
int maxClients = gpGlobals->maxClients;
for (int i=1; i<=maxClients; i++)
{
m_Players[i].DumpAdmin(true);
}
@ -960,7 +963,8 @@ const char *PlayerManager::GetPassInfoVar()
void PlayerManager::RecheckAnyAdmins()
{
for (int i=1; i<=m_maxClients; i++)
int maxClients = gpGlobals->maxClients;
for (int i=1; i<=maxClients; i++)
{
if (m_Players[i].IsInGame() && m_Players[i].IsAuthorized())
{
@ -1354,11 +1358,6 @@ void PlayerManager::ProcessCommandTarget(cmd_target_info_t *info)
}
}
void PlayerManager::OnSourceModMaxPlayersChanged( int newvalue )
{
m_maxClients = newvalue;
}
void PlayerManager::MaxPlayersChanged( int newvalue /*= -1*/ )
{
if (!m_FirstPass)

View File

@ -135,7 +135,6 @@ public: //SMGlobalClass
void OnSourceModShutdown();
void OnSourceModLevelEnd();
ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
void OnSourceModMaxPlayersChanged(int newvalue);
public:
CPlayer *GetPlayerByIndex(int client) const;
void RunAuthChecks();
@ -172,7 +171,7 @@ public: //IPlayerManager
public:
inline int MaxClients()
{
return m_maxClients;
return gpGlobals->maxClients;
}
inline int NumPlayers()
{
@ -206,7 +205,6 @@ private:
IForward *m_onActivate2;
CPlayer *m_Players;
int *m_UserIdLookUp;
int m_maxClients;
int m_PlayerCount;
bool m_FirstPass;
unsigned int *m_AuthQueue;