added new api to IPlayerHelpers for detecting when the server starts up

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401491
This commit is contained in:
David Anderson 2007-09-26 13:12:59 +00:00
parent 5c58cbf624
commit fda5ac1738
3 changed files with 31 additions and 4 deletions

View File

@ -79,7 +79,7 @@ public:
PlayerManager::PlayerManager()
{
m_AuthQueue = NULL;
m_FirstPass = true;
m_FirstPass = false;
m_UserIdLookUp = new int[USHRT_MAX+1];
memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
@ -180,14 +180,14 @@ ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
{
if (m_FirstPass)
if (!m_FirstPass)
{
/* Initialize all players */
m_maxClients = clientMax;
m_PlayerCount = 0;
m_Players = new CPlayer[m_maxClients + 1];
m_AuthQueue = new unsigned int[m_maxClients + 1];
m_FirstPass = false;
m_FirstPass = true;
memset(m_AuthQueue, 0, sizeof(unsigned int) * (m_maxClients + 1));
@ -196,11 +196,22 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
m_onActivate->Execute(NULL);
m_onActivate2->Execute(NULL);
List<IClientListener *>::iterator iter;
for (iter = m_hooks.begin; iter != m_hooks.end(); iter++)
{
(*iter)->OnServerActivated(clientMax);
}
g_OnMapStarted = true;
SM_ExecuteAllConfigs();
}
bool PlayerManager::IsServerActivated()
{
return m_FirstPass;
}
bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
{
const char *password = g_Admins.GetAdminPassword(id);

View File

@ -130,6 +130,7 @@ public: //IPlayerManager
int GetMaxClients();
int GetNumPlayers();
int GetClientOfUserId(int userid);
bool IsServerActivated();
public:
inline int MaxClients()
{

View File

@ -41,7 +41,7 @@
#include <IAdminSystem.h>
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
#define SMINTERFACE_PLAYERMANAGER_VERSION 4
#define SMINTERFACE_PLAYERMANAGER_VERSION 5
struct edict_t;
class IPlayerInfo;
@ -220,6 +220,13 @@ namespace SourceMod
virtual void OnClientAuthorized(int client, const char *authstring)
{
}
/**
* @brief Called when the server is activated.
*/
virtual void OnServerActivated(int max_clients)
{
}
};
class IPlayerManager : public SMInterface
@ -288,6 +295,14 @@ namespace SourceMod
* @return Client index, or 0 if invalid userid passed.
*/
virtual int GetClientOfUserId(int userid) =0;
/**
* @brief Returns whether or not the server is activated.
*
* @return True if ServerActivate() has been called
* at least once, false otherwise.
*/
virtual bool IsServerActivated() =0;
};
}