Executable memory is now provided by MM:S's allocator, this should reduce virtual memory usage.
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 #define PLAYER_LIFE_UNKNOWN 0
48 #define PLAYER_LIFE_ALIVE 1
49 #define PLAYER_LIFE_DEAD 2
51 #define MIN_API_FOR_ADMINCALLS 7
53 class CPlayer : public IGamePlayer
55 friend class PlayerManager;
59 const char *GetName();
60 const char *GetIPAddress();
61 const char *GetAuthString();
64 bool WasCountedAsInGame();
68 void SetAdminId(AdminId id, bool temporary);
70 void Kick(const char *str);
71 IPlayerInfo *GetPlayerInfo();
72 unsigned int GetLanguageId();
74 bool RunAdminCacheChecks();
75 void NotifyPostAdminChecks();
77 void DoBasicAdminChecks();
79 void MarkAsBeingKicked();
82 void Initialize(const char *name, const char *ip, edict_t *pEntity);
85 void SetName(const char *name);
86 void DumpAdmin(bool deleting);
87 void Authorize(const char *auth);
88 void Authorize_Post();
89 void DoPostConnectAuthorization();
94 bool m_bIsInKickQueue;
103 String m_LastPassword;
104 bool m_bAdminCheckSignalled;
106 unsigned int m_LangId;
110 class PlayerManager :
111 public SMGlobalClass,
112 public IPlayerManager
114 friend class CPlayer;
118 public: //SMGlobalClass
119 void OnSourceModAllInitialized();
120 void OnSourceModShutdown();
121 void OnSourceModLevelEnd();
122 ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
124 CPlayer *GetPlayerByIndex(int client) const;
125 void RunAuthChecks();
126 void ClearAdminId(AdminId id);
127 void ClearAllAdmins();
129 bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
130 bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
131 void OnClientPutInServer(edict_t *pEntity, char const *playername);
132 void OnClientDisconnect(edict_t *pEntity);
133 void OnClientDisconnect_Post(edict_t *pEntity);
134 #if defined ORANGEBOX_BUILD
135 void OnClientCommand(edict_t *pEntity, const CCommand &args);
137 void OnClientCommand(edict_t *pEntity);
139 void OnClientSettingsChanged(edict_t *pEntity);
140 //void OnClientSettingsChanged_Pre(edict_t *pEntity);
141 public: //IPlayerManager
142 void AddClientListener(IClientListener *listener);
143 void RemoveClientListener(IClientListener *listener);
144 IGamePlayer *GetGamePlayer(int client);
145 IGamePlayer *GetGamePlayer(edict_t *pEdict);
148 int GetClientOfUserId(int userid);
149 bool IsServerActivated();
150 int FilterCommandTarget(IGamePlayer *pAdmin, IGamePlayer *pTarget, int flags);
151 int InternalFilterCommandTarget(CPlayer *pAdmin, CPlayer *pTarget, int flags);
152 void RegisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
153 void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
154 void ProcessCommandTarget(cmd_target_info_t *info);
156 inline int MaxClients()
160 inline int NumPlayers()
162 return m_PlayerCount;
164 bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
165 bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id);
166 const char *GetPassInfoVar();
167 void RecheckAnyAdmins();
168 unsigned int GetReplyTo();
169 unsigned int SetReplyTo(unsigned int reply);
171 void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
173 List<IClientListener *> m_hooks;
174 IForward *m_clconnect;
175 IForward *m_cldisconnect;
176 IForward *m_cldisconnect_post;
177 IForward *m_clputinserver;
178 IForward *m_clcommand;
179 IForward *m_clinfochanged;
181 IForward *m_onActivate;
182 IForward *m_onActivate2;
188 unsigned int *m_AuthQueue;
189 String m_PassInfoVar;
193 extern PlayerManager g_Players;
194 extern bool g_OnMapStarted;
195 extern const unsigned int *g_NumPlayersToAuth;
197 #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_