1.1 --- a/core/PlayerManager.cpp Fri Nov 14 03:38:59 2008 -0600
1.2 +++ b/core/PlayerManager.cpp Fri Nov 14 09:18:30 2008 -0600
1.3 @@ -61,7 +61,7 @@
1.4 SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int);
1.5 SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *);
1.6 SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *);
1.7 -#if defined ORANGEBOX_BUILD
1.8 +#if SOURCE_ENGINE >= SE_ORANGEBOX
1.9 SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *, const CCommand &);
1.10 #else
1.11 SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
1.12 @@ -69,7 +69,7 @@
1.13 SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
1.14 SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
1.15
1.16 -#if defined ORANGEBOX_BUILD
1.17 +#if SOURCE_ENGINE >= SE_ORANGEBOX
1.18 SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
1.19 #else
1.20 extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
1.21 @@ -151,24 +151,7 @@
1.22
1.23 g_ConVarManager.AddConVarChangeListener("tv_enable", this);
1.24
1.25 - ConCommandBase *pBase = icvar->GetCommands();
1.26 - ConCommand *pCmd = NULL;
1.27 - while (pBase)
1.28 - {
1.29 - if (strcmp(pBase->GetName(), "maxplayers") == 0)
1.30 - {
1.31 - /* Don't want to return convar with same name */
1.32 - if (!pBase->IsCommand())
1.33 - {
1.34 - break;
1.35 - }
1.36 -
1.37 - pCmd = (ConCommand *)pBase;
1.38 - break;
1.39 - }
1.40 - pBase = const_cast<ConCommandBase *>(pBase->GetNext());
1.41 - }
1.42 -
1.43 + ConCommand *pCmd = FindCommand("maxplayers");
1.44 if (pCmd != NULL)
1.45 {
1.46 SH_ADD_HOOK_STATICFUNC(ConCommand, Dispatch, pCmd, CmdMaxplayersCallback, true);
1.47 @@ -408,7 +391,7 @@
1.48
1.49 bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
1.50 {
1.51 - int client = engine->IndexOfEdict(pEntity);
1.52 + int client = IndexOfEdict(pEntity);
1.53 CPlayer *pPlayer = &m_Players[client];
1.54
1.55 List<IClientListener *>::iterator iter;
1.56 @@ -452,7 +435,7 @@
1.57
1.58 bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
1.59 {
1.60 - int client = engine->IndexOfEdict(pEntity);
1.61 + int client = IndexOfEdict(pEntity);
1.62 bool orig_value = META_RESULT_ORIG_RET(bool);
1.63 CPlayer *pPlayer = &m_Players[client];
1.64
1.65 @@ -492,7 +475,7 @@
1.66 void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername)
1.67 {
1.68 cell_t res;
1.69 - int client = engine->IndexOfEdict(pEntity);
1.70 + int client = IndexOfEdict(pEntity);
1.71 CPlayer *pPlayer = &m_Players[client];
1.72
1.73 /* If they're not connected, they're a bot */
1.74 @@ -590,7 +573,7 @@
1.75 void PlayerManager::OnClientDisconnect(edict_t *pEntity)
1.76 {
1.77 cell_t res;
1.78 - int client = engine->IndexOfEdict(pEntity);
1.79 + int client = IndexOfEdict(pEntity);
1.80 CPlayer *pPlayer = &m_Players[client];
1.81
1.82 if (pPlayer->IsConnected())
1.83 @@ -628,7 +611,7 @@
1.84 void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity)
1.85 {
1.86 cell_t res;
1.87 - int client = engine->IndexOfEdict(pEntity);
1.88 + int client = IndexOfEdict(pEntity);
1.89
1.90 m_cldisconnect_post->PushCell(client);
1.91 m_cldisconnect_post->Execute(&res, NULL);
1.92 @@ -642,7 +625,7 @@
1.93 }
1.94 }
1.95
1.96 -#if defined ORANGEBOX_BUILD
1.97 +#if SOURCE_ENGINE >= SE_ORANGEBOX
1.98 void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args)
1.99 {
1.100 #else
1.101 @@ -650,7 +633,7 @@
1.102 {
1.103 CCommand args;
1.104 #endif
1.105 - int client = engine->IndexOfEdict(pEntity);
1.106 + int client = IndexOfEdict(pEntity);
1.107 cell_t res = Pl_Continue;
1.108 CPlayer *pPlayer = &m_Players[client];
1.109
1.110 @@ -705,7 +688,7 @@
1.111 void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
1.112 {
1.113 cell_t res;
1.114 - int client = engine->IndexOfEdict(pEntity);
1.115 + int client = IndexOfEdict(pEntity);
1.116 CPlayer *pPlayer = &m_Players[client];
1.117
1.118 if (!pPlayer->IsConnected())
1.119 @@ -713,7 +696,7 @@
1.120 return;
1.121 }
1.122
1.123 - m_clinfochanged->PushCell(engine->IndexOfEdict(pEntity));
1.124 + m_clinfochanged->PushCell(client);
1.125 m_clinfochanged->Execute(&res, NULL);
1.126
1.127 IPlayerInfo *info = pPlayer->GetPlayerInfo();
1.128 @@ -833,7 +816,7 @@
1.129
1.130 IGamePlayer *PlayerManager::GetGamePlayer(edict_t *pEdict)
1.131 {
1.132 - int index = engine->IndexOfEdict(pEdict);
1.133 + int index = IndexOfEdict(pEdict);
1.134 return GetGamePlayer(index);
1.135 }
1.136
1.137 @@ -1304,7 +1287,7 @@
1.138 }
1.139 }
1.140
1.141 -#if defined ORANGEBOX_BUILD
1.142 +#if SOURCE_ENGINE >= SE_ORANGEBOX
1.143 void CmdMaxplayersCallback(const CCommand &command)
1.144 {
1.145 #else
1.146 @@ -1342,7 +1325,7 @@
1.147 m_Name.assign(name);
1.148 m_Ip.assign(ip);
1.149 m_pEdict = pEntity;
1.150 - m_iIndex = engine->IndexOfEdict(pEntity);
1.151 + m_iIndex = IndexOfEdict(pEntity);
1.152 m_LangId = g_Translator.GetServerLanguage();
1.153
1.154 char ip2[24], *ptr;
1.155 @@ -1364,7 +1347,7 @@
1.156 m_IsInGame = true;
1.157
1.158 const char *var = g_Players.GetPassInfoVar();
1.159 - int client = engine->IndexOfEdict(m_pEdict);
1.160 + int client = IndexOfEdict(m_pEdict);
1.161 if (var[0] != '\0')
1.162 {
1.163 const char *pass = engine->GetClientConVarValue(client, var);
1.164 @@ -1611,7 +1594,7 @@
1.165
1.166 /* First check the name */
1.167 AdminId id;
1.168 - int client = engine->IndexOfEdict(m_pEdict);
1.169 + int client = IndexOfEdict(m_pEdict);
1.170
1.171 if ((id = g_Admins.FindAdminByIdentity("name", GetName())) != INVALID_ADMIN_ID)
1.172 {