core/CPlayerManager.h
author Borja Ferrer <faluco@alliedmods.net>
Fri Jan 05 00:58:28 2007 +0000 (2007-01-05)
changeset 269 0658b8daeba6
parent 268 d6fed4f05e07
child 370 d3a484f98f6d
permissions -rw-r--r--
whoa this caused a memory LEEK
     1 #ifndef _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
     2 #define _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
     3 
     4 #include "sm_globals.h"
     5 #include <eiface.h>
     6 #include "sourcemm_api.h"
     7 #include <IForwardSys.h>
     8 #include "CPlayer.h"
     9 
    10 class CPlayer;
    11 
    12 class CPlayerManager : public SMGlobalClass
    13 {
    14 public:
    15 	CPlayerManager() : m_FirstPass(true) {}
    16 public: //SMGlobalClass
    17 	virtual void OnSourceModAllInitialized();
    18 	virtual void OnSourceModShutdown();
    19 public:
    20 	int GetMaxClients() const;
    21 	CPlayer *GetPlayerByIndex(int client) const;
    22 	int GetPlayerCount() const;
    23 public:
    24 	bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
    25 	void OnClientPutInServer(edict_t *pEntity, char const *playername);
    26 	void OnClientDisconnect(edict_t *pEntity);
    27 	void OnClientDisconnect_Post(edict_t *pEntity);
    28 	void OnClientAuthorized(); //:TODO: any args needed?
    29 	void OnClientCommand(edict_t *pEntity);
    30 	void OnClientSettingsChanged(edict_t *pEntity);
    31 private:
    32 	void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
    33 private:
    34 	IForward *m_clconnect;
    35 	IForward *m_cldisconnect;
    36 	IForward *m_cldisconnect_post;
    37 	IForward *m_clputinserver;
    38 	IForward *m_clcommand;
    39 	IForward *m_clinfochanged;
    40 	CPlayer *m_Players;
    41 	int m_maxClients;
    42 	int m_PlayerCount;
    43 	bool m_FirstPass;
    44 };
    45 
    46 extern CPlayerManager g_PlayerManager;
    47 
    48 inline int CPlayerManager::GetMaxClients() const
    49 {
    50 	return m_maxClients;
    51 }
    52 
    53 inline CPlayer *CPlayerManager::GetPlayerByIndex(int client) const
    54 {
    55 	if (client > m_maxClients || client < 0)
    56 	{
    57 		return NULL;
    58 	}
    59 	return &m_Players[client];
    60 }
    61 
    62 inline int CPlayerManager::GetPlayerCount() const
    63 {
    64 	return m_PlayerCount;
    65 }
    66 
    67 #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_