core/CPlayerManager.h
author David Anderson <dvander@alliedmods.net>
Sat Jan 27 04:50:48 2007 +0000 (2007-01-27)
changeset 398 626ce2e591ad
parent 370 d3a484f98f6d
child 430 ed37e9767ed4
permissions -rw-r--r--
fixed a bug in the admin plugin
     1 /**
     2  * ===============================================================
     3  * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
     4  * ===============================================================
     5  *
     6  * This file is not open source and may not be copied without explicit
     7  * written permission of AlliedModders LLC.  This file may not be redistributed 
     8  * in whole or significant part.
     9  * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
    10  *
    11  * Version: $Id$
    12  */
    13 
    14 #ifndef _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
    15 #define _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
    16 
    17 #include "sm_globals.h"
    18 #include <eiface.h>
    19 #include "sourcemm_api.h"
    20 #include <IForwardSys.h>
    21 #include "CPlayer.h"
    22 
    23 class CPlayer;
    24 
    25 class CPlayerManager : public SMGlobalClass
    26 {
    27 public:
    28 	CPlayerManager() : m_FirstPass(true) {}
    29 public: //SMGlobalClass
    30 	virtual void OnSourceModAllInitialized();
    31 	virtual void OnSourceModShutdown();
    32 public:
    33 	int GetMaxClients() const;
    34 	CPlayer *GetPlayerByIndex(int client) const;
    35 	int GetPlayerCount() const;
    36 public:
    37 	bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
    38 	void OnClientPutInServer(edict_t *pEntity, char const *playername);
    39 	void OnClientDisconnect(edict_t *pEntity);
    40 	void OnClientDisconnect_Post(edict_t *pEntity);
    41 	void OnClientAuthorized(); //:TODO: any args needed?
    42 	void OnClientCommand(edict_t *pEntity);
    43 	void OnClientSettingsChanged(edict_t *pEntity);
    44 private:
    45 	void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
    46 private:
    47 	IForward *m_clconnect;
    48 	IForward *m_cldisconnect;
    49 	IForward *m_cldisconnect_post;
    50 	IForward *m_clputinserver;
    51 	IForward *m_clcommand;
    52 	IForward *m_clinfochanged;
    53 	CPlayer *m_Players;
    54 	int m_maxClients;
    55 	int m_PlayerCount;
    56 	bool m_FirstPass;
    57 };
    58 
    59 extern CPlayerManager g_PlayerManager;
    60 
    61 inline int CPlayerManager::GetMaxClients() const
    62 {
    63 	return m_maxClients;
    64 }
    65 
    66 inline CPlayer *CPlayerManager::GetPlayerByIndex(int client) const
    67 {
    68 	if (client > m_maxClients || client < 0)
    69 	{
    70 		return NULL;
    71 	}
    72 	return &m_Players[client];
    73 }
    74 
    75 inline int CPlayerManager::GetPlayerCount() const
    76 {
    77 	return m_PlayerCount;
    78 }
    79 
    80 #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_