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();
61 void SetAdminId(AdminId id, bool temporary);
63 void Kick(const char *str);
64 IPlayerInfo *GetPlayerInfo();
65 unsigned int GetLanguageId();
68 void NotifyPostAdminChecks();
69 void DoBasicAdminChecks();
71 void Initialize(const char *name, const char *ip, edict_t *pEntity);
74 void SetName(const char *name);
75 void DumpAdmin(bool deleting);
76 void Authorize(const char *auth);
77 void Authorize_Post();
78 void DoPostConnectAuthorization();
91 String m_LastPassword;
92 bool m_bAdminCheckSignalled;
94 unsigned int m_LangId;
95 QueryCvarCookie_t m_LangCookie;
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);
133 void HandleLangQuery(int userid, const char *value, QueryCvarCookie_t cookie);
135 inline int MaxClients()
139 inline int NumPlayers()
141 return m_PlayerCount;
143 bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
144 bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id);
145 const char *GetPassInfoVar();
146 void RecheckAnyAdmins();
148 void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
150 List<IClientListener *> m_hooks;
151 IForward *m_clconnect;
152 IForward *m_cldisconnect;
153 IForward *m_cldisconnect_post;
154 IForward *m_clputinserver;
155 IForward *m_clcommand;
156 IForward *m_clinfochanged;
158 IForward *m_onActivate;
159 IForward *m_onActivate2;
165 unsigned int *m_AuthQueue;
166 String m_PassInfoVar;
170 extern PlayerManager g_Players;
171 extern bool g_OnMapStarted;
173 #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_