core/PlayerManager.h
branchrefac-jit
changeset 2284 026da5437111
parent 2192 7602d7fb60d9
child 2288 15c77b21589a
     1.1 --- a/core/PlayerManager.h	Fri Jul 11 06:51:21 2008 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,203 +0,0 @@
     1.4 -/**
     1.5 - * vim: set ts=4 :
     1.6 - * =============================================================================
     1.7 - * SourceMod
     1.8 - * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
     1.9 - * =============================================================================
    1.10 - *
    1.11 - * This program is free software; you can redistribute it and/or modify it under
    1.12 - * the terms of the GNU General Public License, version 3.0, as published by the
    1.13 - * Free Software Foundation.
    1.14 - * 
    1.15 - * This program is distributed in the hope that it will be useful, but WITHOUT
    1.16 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    1.17 - * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    1.18 - * details.
    1.19 - *
    1.20 - * You should have received a copy of the GNU General Public License along with
    1.21 - * this program.  If not, see <http://www.gnu.org/licenses/>.
    1.22 - *
    1.23 - * As a special exception, AlliedModders LLC gives you permission to link the
    1.24 - * code of this program (as well as its derivative works) to "Half-Life 2," the
    1.25 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    1.26 - * by the Valve Corporation.  You must obey the GNU General Public License in
    1.27 - * all respects for all other code used.  Additionally, AlliedModders LLC grants
    1.28 - * this exception to all derivative works.  AlliedModders LLC defines further
    1.29 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    1.30 - * or <http://www.sourcemod.net/license.php>.
    1.31 - *
    1.32 - * Version: $Id$
    1.33 - */
    1.34 -
    1.35 -#ifndef _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
    1.36 -#define _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
    1.37 -
    1.38 -#include "sm_globals.h"
    1.39 -#include <eiface.h>
    1.40 -#include "sourcemm_api.h"
    1.41 -#include <IForwardSys.h>
    1.42 -#include <IPlayerHelpers.h>
    1.43 -#include <IAdminSystem.h>
    1.44 -#include <sh_string.h>
    1.45 -#include <sh_list.h>
    1.46 -#include <sh_vector.h>
    1.47 -
    1.48 -using namespace SourceHook;
    1.49 -
    1.50 -#define PLAYER_LIFE_UNKNOWN	0
    1.51 -#define PLAYER_LIFE_ALIVE	1
    1.52 -#define PLAYER_LIFE_DEAD	2
    1.53 -
    1.54 -#define MIN_API_FOR_ADMINCALLS		7
    1.55 -
    1.56 -class CPlayer : public IGamePlayer
    1.57 -{
    1.58 -	friend class PlayerManager;
    1.59 -public:
    1.60 -	CPlayer();
    1.61 -public:
    1.62 -	const char *GetName();
    1.63 -	const char *GetIPAddress();
    1.64 -	const char *GetAuthString();
    1.65 -	edict_t *GetEdict();
    1.66 -	bool IsInGame();
    1.67 -	bool WasCountedAsInGame();
    1.68 -	bool IsConnected();
    1.69 -	bool IsAuthorized();
    1.70 -	bool IsFakeClient();
    1.71 -	void SetAdminId(AdminId id, bool temporary);
    1.72 -	AdminId GetAdminId();
    1.73 -	void Kick(const char *str);
    1.74 -	IPlayerInfo *GetPlayerInfo();
    1.75 -	unsigned int GetLanguageId();
    1.76 -	int GetUserId();
    1.77 -	bool RunAdminCacheChecks();
    1.78 -	void NotifyPostAdminChecks();
    1.79 -public:
    1.80 -	void DoBasicAdminChecks();
    1.81 -	bool IsInKickQueue();
    1.82 -	void MarkAsBeingKicked();
    1.83 -	int GetLifeState();
    1.84 -private:
    1.85 -	void Initialize(const char *name, const char *ip, edict_t *pEntity);
    1.86 -	void Connect();
    1.87 -	void Disconnect();
    1.88 -	void SetName(const char *name);
    1.89 -	void DumpAdmin(bool deleting);
    1.90 -	void Authorize(const char *auth);
    1.91 -	void Authorize_Post();
    1.92 -	void DoPostConnectAuthorization();
    1.93 -private:
    1.94 -	bool m_IsConnected;
    1.95 -	bool m_IsInGame;
    1.96 -	bool m_IsAuthorized;
    1.97 -	bool m_bIsInKickQueue;
    1.98 -	String m_Name;
    1.99 -	String m_Ip;
   1.100 -	String m_IpNoPort;
   1.101 -	String m_AuthID;
   1.102 -	AdminId m_Admin;
   1.103 -	bool m_TempAdmin;
   1.104 -	edict_t *m_pEdict;
   1.105 -	IPlayerInfo *m_Info;
   1.106 -	String m_LastPassword;
   1.107 -	bool m_bAdminCheckSignalled;
   1.108 -	int m_iIndex;
   1.109 -	unsigned int m_LangId;
   1.110 -	int m_UserId;
   1.111 -};
   1.112 -
   1.113 -class PlayerManager : 
   1.114 -	public SMGlobalClass,
   1.115 -	public IPlayerManager
   1.116 -{
   1.117 -	friend class CPlayer;
   1.118 -public:
   1.119 -	PlayerManager();
   1.120 -	~PlayerManager();
   1.121 -public: //SMGlobalClass
   1.122 -	void OnSourceModAllInitialized();
   1.123 -	void OnSourceModShutdown();
   1.124 -	void OnSourceModLevelEnd();
   1.125 -	ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
   1.126 -public:
   1.127 -	CPlayer *GetPlayerByIndex(int client) const;
   1.128 -	void RunAuthChecks();
   1.129 -	void ClearAdminId(AdminId id);
   1.130 -	void ClearAllAdmins();
   1.131 -public:
   1.132 -	bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
   1.133 -	bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
   1.134 -	void OnClientPutInServer(edict_t *pEntity, char const *playername);
   1.135 -	void OnClientDisconnect(edict_t *pEntity);
   1.136 -	void OnClientDisconnect_Post(edict_t *pEntity);
   1.137 -#if defined ORANGEBOX_BUILD
   1.138 -	void OnClientCommand(edict_t *pEntity, const CCommand &args);
   1.139 -#else
   1.140 -	void OnClientCommand(edict_t *pEntity);
   1.141 -#endif
   1.142 -	void OnClientSettingsChanged(edict_t *pEntity);
   1.143 -	//void OnClientSettingsChanged_Pre(edict_t *pEntity);
   1.144 -public: //IPlayerManager
   1.145 -	void AddClientListener(IClientListener *listener);
   1.146 -	void RemoveClientListener(IClientListener *listener);
   1.147 -	IGamePlayer *GetGamePlayer(int client);
   1.148 -	IGamePlayer *GetGamePlayer(edict_t *pEdict);
   1.149 -	int GetMaxClients();
   1.150 -	int GetNumPlayers();
   1.151 -	int GetClientOfUserId(int userid);
   1.152 -	bool IsServerActivated();
   1.153 -	int FilterCommandTarget(IGamePlayer *pAdmin, IGamePlayer *pTarget, int flags);
   1.154 -	int InternalFilterCommandTarget(CPlayer *pAdmin, CPlayer *pTarget, int flags);
   1.155 -	void RegisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
   1.156 -	void UnregisterCommandTargetProcessor(ICommandTargetProcessor *pHandler);
   1.157 -	void ProcessCommandTarget(cmd_target_info_t *info);
   1.158 -public:
   1.159 -	inline int MaxClients()
   1.160 -	{
   1.161 -		return m_maxClients;
   1.162 -	}
   1.163 -	inline int NumPlayers()
   1.164 -	{
   1.165 -		return m_PlayerCount;
   1.166 -	}
   1.167 -	inline int ListenClient()
   1.168 -	{
   1.169 -		return m_ListenClient;
   1.170 -	}
   1.171 -	bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
   1.172 -	bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id);
   1.173 -	const char *GetPassInfoVar();
   1.174 -	void RecheckAnyAdmins();
   1.175 -	unsigned int GetReplyTo();
   1.176 -	unsigned int SetReplyTo(unsigned int reply);
   1.177 -private:
   1.178 -	void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
   1.179 -private:
   1.180 -	List<IClientListener *> m_hooks;
   1.181 -	IForward *m_clconnect;
   1.182 -	IForward *m_cldisconnect;
   1.183 -	IForward *m_cldisconnect_post;
   1.184 -	IForward *m_clputinserver;
   1.185 -	IForward *m_clcommand;
   1.186 -	IForward *m_clinfochanged;
   1.187 -	IForward *m_clauth;
   1.188 -	IForward *m_onActivate;
   1.189 -	IForward *m_onActivate2;
   1.190 -	CPlayer *m_Players;
   1.191 -	int *m_UserIdLookUp;
   1.192 -	int m_maxClients;
   1.193 -	int m_PlayerCount;
   1.194 -	bool m_FirstPass;
   1.195 -	unsigned int *m_AuthQueue;
   1.196 -	String m_PassInfoVar;
   1.197 -	bool m_QueryLang;
   1.198 -	bool m_bIsListenServer;
   1.199 -	int m_ListenClient;
   1.200 -};
   1.201 -
   1.202 -extern PlayerManager g_Players;
   1.203 -extern bool g_OnMapStarted;
   1.204 -extern const unsigned int *g_NumPlayersToAuth;
   1.205 -
   1.206 -#endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_