3 * =============================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
33 #define _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
35 #include "sm_globals.h"
37 #include "sourcemm_api.h"
38 #include <IForwardSys.h>
39 #include <IPlayerHelpers.h>
40 #include <IAdminSystem.h>
41 #include <sh_string.h>
43 #include <sh_vector.h>
45 using namespace SourceHook;
47 class CPlayer : public IGamePlayer
49 friend class PlayerManager;
53 const char *GetName();
54 const char *GetIPAddress();
55 const char *GetAuthString();
58 bool WasCountedAsInGame();
62 void SetAdminId(AdminId id, bool temporary);
64 void Kick(const char *str);
65 IPlayerInfo *GetPlayerInfo();
66 unsigned int GetLanguageId();
69 void NotifyPostAdminChecks();
70 void DoBasicAdminChecks();
72 void Initialize(const char *name, const char *ip, edict_t *pEntity);
75 void SetName(const char *name);
76 void DumpAdmin(bool deleting);
77 void Authorize(const char *auth);
78 void Authorize_Post();
79 void DoPostConnectAuthorization();
92 String m_LastPassword;
93 bool m_bAdminCheckSignalled;
95 unsigned int m_LangId;
100 public SMGlobalClass,
101 public IPlayerManager
106 public: //SMGlobalClass
107 void OnSourceModAllInitialized();
108 void OnSourceModShutdown();
109 void OnSourceModLevelEnd();
110 ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
112 CPlayer *GetPlayerByIndex(int client) const;
113 void RunAuthChecks();
114 void ClearAdminId(AdminId id);
115 void ClearAllAdmins();
117 bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
118 bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
119 void OnClientPutInServer(edict_t *pEntity, char const *playername);
120 void OnClientDisconnect(edict_t *pEntity);
121 void OnClientDisconnect_Post(edict_t *pEntity);
122 void OnClientCommand(edict_t *pEntity);
123 void OnClientSettingsChanged(edict_t *pEntity);
124 //void OnClientSettingsChanged_Pre(edict_t *pEntity);
125 public: //IPlayerManager
126 void AddClientListener(IClientListener *listener);
127 void RemoveClientListener(IClientListener *listener);
128 IGamePlayer *GetGamePlayer(int client);
129 IGamePlayer *GetGamePlayer(edict_t *pEdict);
132 int GetClientOfUserId(int userid);
134 inline int MaxClients()
138 inline int NumPlayers()
140 return m_PlayerCount;
142 bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
143 bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id);
144 const char *GetPassInfoVar();
145 void RecheckAnyAdmins();
147 void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
149 List<IClientListener *> m_hooks;
150 IForward *m_clconnect;
151 IForward *m_cldisconnect;
152 IForward *m_cldisconnect_post;
153 IForward *m_clputinserver;
154 IForward *m_clcommand;
155 IForward *m_clinfochanged;
157 IForward *m_onActivate;
158 IForward *m_onActivate2;
164 unsigned int *m_AuthQueue;
165 String m_PassInfoVar;
169 extern PlayerManager g_Players;
170 extern bool g_OnMapStarted;
172 #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_