Fixed more crashes related to early, nonzero maxclients (bug 5008, r=dvander).
Fixed more crashes related to early, nonzero maxclients (
bug 5008, r=dvander).
1.1 --- a/core/PlayerManager.cpp Thu Jul 07 19:53:56 2011 -0400
1.2 +++ b/core/PlayerManager.cpp Thu Jul 07 21:31:07 2011 -0400
1.3 @@ -274,7 +274,7 @@
1.4 SM_ExecuteAllConfigs();
1.5 }
1.6
1.7 -bool PlayerManager::IsServerActivated()
1.8 +bool PlayerManager::IsServerActivated() const
1.9 {
1.10 return m_FirstPass;
1.11 }
1.12 @@ -856,7 +856,7 @@
1.13
1.14 CPlayer *PlayerManager::GetPlayerByIndex(int client) const
1.15 {
1.16 - if (client > gpGlobals->maxClients || client < 1)
1.17 + if (!IsServerActivated() || client > gpGlobals->maxClients || client < 1)
1.18 {
1.19 return NULL;
1.20 }
1.21 @@ -937,6 +937,12 @@
1.22
1.23 void PlayerManager::ClearAdminId(AdminId id)
1.24 {
1.25 + // Players may not be inited if server hasn't yet been activated
1.26 + if (!IsServerActivated())
1.27 + {
1.28 + return;
1.29 + }
1.30 +
1.31 int maxClients = gpGlobals->maxClients;
1.32 for (int i=1; i<=maxClients; i++)
1.33 {
1.34 @@ -949,8 +955,8 @@
1.35
1.36 void PlayerManager::ClearAllAdmins()
1.37 {
1.38 - // Players may not be inited if server hadn't been activated
1.39 - if (!m_Players)
1.40 + // Players may not be inited if server hasn't yet been activated
1.41 + if (!IsServerActivated())
1.42 {
1.43 return;
1.44 }
1.45 @@ -969,8 +975,8 @@
1.46
1.47 void PlayerManager::RecheckAnyAdmins()
1.48 {
1.49 - // Players may not be inited if server hadn't been activated
1.50 - if (!m_Players)
1.51 + // Players may not be inited if server hasn't yet been activated
1.52 + if (!IsServerActivated())
1.53 {
1.54 return;
1.55 }
2.1 --- a/core/PlayerManager.h Thu Jul 07 19:53:56 2011 -0400
2.2 +++ b/core/PlayerManager.h Thu Jul 07 21:31:07 2011 -0400
2.3 @@ -161,7 +161,7 @@
2.4 int GetMaxClients();
2.5 int GetNumPlayers();
2.6 int GetClientOfUserId(int userid);
2.7 - bool IsServerActivated();
2.8 + bool IsServerActivated() const;
2.9 int FilterCommandTarget(IGamePlayer *pAdmin, IGamePlayer *pTarget, int flags);
2.10 int InternalFilterCommandTarget(CPlayer *pAdmin, CPlayer *pTarget, int flags);
2.11 void RegisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
3.1 --- a/public/IPlayerHelpers.h Thu Jul 07 19:53:56 2011 -0400
3.2 +++ b/public/IPlayerHelpers.h Thu Jul 07 21:31:07 2011 -0400
3.3 @@ -41,7 +41,7 @@
3.4 #include <IAdminSystem.h>
3.5
3.6 #define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
3.7 -#define SMINTERFACE_PLAYERMANAGER_VERSION 14
3.8 +#define SMINTERFACE_PLAYERMANAGER_VERSION 15
3.9
3.10 struct edict_t;
3.11 class IPlayerInfo;
3.12 @@ -489,7 +489,7 @@
3.13 * @return True if ServerActivate() has been called
3.14 * at least once, false otherwise.
3.15 */
3.16 - virtual bool IsServerActivated() =0;
3.17 + virtual bool IsServerActivated() const =0;
3.18
3.19 /**
3.20 * @brief Gets SourceMod's reply source.