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:
parent
5c58cbf624
commit
fda5ac1738
@ -79,7 +79,7 @@ public:
|
|||||||
PlayerManager::PlayerManager()
|
PlayerManager::PlayerManager()
|
||||||
{
|
{
|
||||||
m_AuthQueue = NULL;
|
m_AuthQueue = NULL;
|
||||||
m_FirstPass = true;
|
m_FirstPass = false;
|
||||||
|
|
||||||
m_UserIdLookUp = new int[USHRT_MAX+1];
|
m_UserIdLookUp = new int[USHRT_MAX+1];
|
||||||
memset(m_UserIdLookUp, 0, sizeof(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)
|
void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
|
||||||
{
|
{
|
||||||
if (m_FirstPass)
|
if (!m_FirstPass)
|
||||||
{
|
{
|
||||||
/* Initialize all players */
|
/* Initialize all players */
|
||||||
m_maxClients = clientMax;
|
m_maxClients = clientMax;
|
||||||
m_PlayerCount = 0;
|
m_PlayerCount = 0;
|
||||||
m_Players = new CPlayer[m_maxClients + 1];
|
m_Players = new CPlayer[m_maxClients + 1];
|
||||||
m_AuthQueue = new unsigned int[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));
|
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_onActivate->Execute(NULL);
|
||||||
m_onActivate2->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;
|
g_OnMapStarted = true;
|
||||||
|
|
||||||
SM_ExecuteAllConfigs();
|
SM_ExecuteAllConfigs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PlayerManager::IsServerActivated()
|
||||||
|
{
|
||||||
|
return m_FirstPass;
|
||||||
|
}
|
||||||
|
|
||||||
bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
|
bool PlayerManager::CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id)
|
||||||
{
|
{
|
||||||
const char *password = g_Admins.GetAdminPassword(id);
|
const char *password = g_Admins.GetAdminPassword(id);
|
||||||
|
@ -130,6 +130,7 @@ public: //IPlayerManager
|
|||||||
int GetMaxClients();
|
int GetMaxClients();
|
||||||
int GetNumPlayers();
|
int GetNumPlayers();
|
||||||
int GetClientOfUserId(int userid);
|
int GetClientOfUserId(int userid);
|
||||||
|
bool IsServerActivated();
|
||||||
public:
|
public:
|
||||||
inline int MaxClients()
|
inline int MaxClients()
|
||||||
{
|
{
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <IAdminSystem.h>
|
#include <IAdminSystem.h>
|
||||||
|
|
||||||
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
|
#define SMINTERFACE_PLAYERMANAGER_NAME "IPlayerManager"
|
||||||
#define SMINTERFACE_PLAYERMANAGER_VERSION 4
|
#define SMINTERFACE_PLAYERMANAGER_VERSION 5
|
||||||
|
|
||||||
struct edict_t;
|
struct edict_t;
|
||||||
class IPlayerInfo;
|
class IPlayerInfo;
|
||||||
@ -220,6 +220,13 @@ namespace SourceMod
|
|||||||
virtual void OnClientAuthorized(int client, const char *authstring)
|
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
|
class IPlayerManager : public SMInterface
|
||||||
@ -288,6 +295,14 @@ namespace SourceMod
|
|||||||
* @return Client index, or 0 if invalid userid passed.
|
* @return Client index, or 0 if invalid userid passed.
|
||||||
*/
|
*/
|
||||||
virtual int GetClientOfUserId(int userid) =0;
|
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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user