Fixed more crashes related to early, nonzero maxclients (bug 5008, r=dvander).

This commit is contained in:
Nicholas Hastings 2011-07-07 21:31:07 -04:00
parent e09d4f2cf2
commit 51c27afcd2
3 changed files with 15 additions and 9 deletions

View File

@ -274,7 +274,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
SM_ExecuteAllConfigs();
}
bool PlayerManager::IsServerActivated()
bool PlayerManager::IsServerActivated() const
{
return m_FirstPass;
}
@ -856,7 +856,7 @@ int PlayerManager::GetMaxClients()
CPlayer *PlayerManager::GetPlayerByIndex(int client) const
{
if (client > gpGlobals->maxClients || client < 1)
if (!IsServerActivated() || client > gpGlobals->maxClients || client < 1)
{
return NULL;
}
@ -937,6 +937,12 @@ IGamePlayer *PlayerManager::GetGamePlayer(int client)
void PlayerManager::ClearAdminId(AdminId id)
{
// Players may not be inited if server hasn't yet been activated
if (!IsServerActivated())
{
return;
}
int maxClients = gpGlobals->maxClients;
for (int i=1; i<=maxClients; i++)
{
@ -949,8 +955,8 @@ void PlayerManager::ClearAdminId(AdminId id)
void PlayerManager::ClearAllAdmins()
{
// Players may not be inited if server hadn't been activated
if (!m_Players)
// Players may not be inited if server hasn't yet been activated
if (!IsServerActivated())
{
return;
}
@ -969,8 +975,8 @@ const char *PlayerManager::GetPassInfoVar()
void PlayerManager::RecheckAnyAdmins()
{
// Players may not be inited if server hadn't been activated
if (!m_Players)
// Players may not be inited if server hasn't yet been activated
if (!IsServerActivated())
{
return;
}

View File

@ -161,7 +161,7 @@ public: //IPlayerManager
int GetMaxClients();
int GetNumPlayers();
int GetClientOfUserId(int userid);
bool IsServerActivated();
bool IsServerActivated() const;
int FilterCommandTarget(IGamePlayer *pAdmin, IGamePlayer *pTarget, int flags);
int InternalFilterCommandTarget(CPlayer *pAdmin, CPlayer *pTarget, int flags);
void RegisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);

View File

@ -41,7 +41,7 @@
#include <IAdminSystem.h>
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
#define SMINTERFACE_PLAYERMANAGER_VERSION 14
#define SMINTERFACE_PLAYERMANAGER_VERSION 15
struct edict_t;
class IPlayerInfo;
@ -489,7 +489,7 @@ namespace SourceMod
* @return True if ServerActivate() has been called
* at least once, false otherwise.
*/
virtual bool IsServerActivated() =0;
virtual bool IsServerActivated() const =0;
/**
* @brief Gets SourceMod's reply source.