1.1 --- a/core/PlayerManager.cpp Mon May 13 14:19:17 2013 -0400
1.2 +++ b/core/PlayerManager.cpp Mon May 13 15:18:12 2013 -0400
1.3 @@ -58,6 +58,13 @@
1.4 int lifestate_offset = -1;
1.5 List<ICommandTargetProcessor *> target_processors;
1.6
1.7 +#if SOURCE_ENGINE == SE_DOTA
1.8 +SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, int, const char *, const char *, char *, int);
1.9 +SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, int, const char *);
1.10 +SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, int);
1.11 +SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, int, const CCommand &);
1.12 +SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, int);
1.13 +#else
1.14 SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int);
1.15 SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *);
1.16 SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *);
1.17 @@ -67,6 +74,7 @@
1.18 SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
1.19 #endif
1.20 SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
1.21 +#endif // SE_DOTA
1.22
1.23 #if SOURCE_ENGINE == SE_DOTA
1.24 SH_DECL_HOOK0_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0);
1.25 @@ -380,7 +388,11 @@
1.26 for (unsigned int i=1; i<=m_AuthQueue[0]; i++)
1.27 {
1.28 pPlayer = &m_Players[m_AuthQueue[i]];
1.29 +#if SOURCE_ENGINE == SE_DOTA
1.30 + authstr = engine->GetPlayerNetworkIDString(pPlayer->m_iIndex - 1);
1.31 +#else
1.32 authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict);
1.33 +#endif
1.34 pPlayer->SetAuthString(authstr);
1.35
1.36 if (!pPlayer->IsAuthStringValidated())
1.37 @@ -457,9 +469,15 @@
1.38 }
1.39 }
1.40
1.41 +#if SOURCE_ENGINE == SE_DOTA
1.42 +bool PlayerManager::OnClientConnect(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
1.43 +{
1.44 + edict_t *pEntity = PEntityOfEntIndex(client);
1.45 +#else
1.46 bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
1.47 {
1.48 int client = IndexOfEdict(pEntity);
1.49 +#endif
1.50 CPlayer *pPlayer = &m_Players[client];
1.51 ++m_PlayersSinceActive;
1.52
1.53 @@ -503,7 +521,7 @@
1.54 m_AuthQueue[++m_AuthQueue[0]] = client;
1.55 }
1.56
1.57 - m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = client;
1.58 + m_UserIdLookUp[GetPlayerUserId(pEntity)] = client;
1.59 }
1.60 else
1.61 {
1.62 @@ -516,9 +534,16 @@
1.63 return true;
1.64 }
1.65
1.66 +#if SOURCE_ENGINE == SE_DOTA
1.67 +bool PlayerManager::OnClientConnect_Post(int client, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
1.68 +{
1.69 + edict_t *pEntity = PEntityOfEntIndex(client);
1.70 +#else
1.71 bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
1.72 {
1.73 int client = IndexOfEdict(pEntity);
1.74 +#endif
1.75 +
1.76 bool orig_value = META_RESULT_ORIG_RET(bool);
1.77 CPlayer *pPlayer = &m_Players[client];
1.78
1.79 @@ -555,10 +580,17 @@
1.80 return true;
1.81 }
1.82
1.83 +#if SOURCE_ENGINE == SE_DOTA
1.84 +void PlayerManager::OnClientPutInServer(int client, const char *playername)
1.85 +{
1.86 + edict_t *pEntity = PEntityOfEntIndex(client);
1.87 +#else
1.88 void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername)
1.89 {
1.90 + int client = IndexOfEdict(pEntity);
1.91 +#endif
1.92 +
1.93 cell_t res;
1.94 - int client = IndexOfEdict(pEntity);
1.95 CPlayer *pPlayer = &m_Players[client];
1.96
1.97 /* If they're not connected, they're a bot */
1.98 @@ -566,7 +598,12 @@
1.99 {
1.100 /* Run manual connection routines */
1.101 char error[255];
1.102 - const char *authid = engine->GetPlayerNetworkIDString(pEntity);
1.103 + const char *authid;
1.104 +#if SOURCE_ENGINE == SE_DOTA
1.105 + authid = engine->GetPlayerNetworkIDString(client - 1);
1.106 +#else
1.107 + authid = engine->GetPlayerNetworkIDString(pEntity);
1.108 +#endif
1.109 pPlayer->SetAuthString(authid);
1.110 pPlayer->Authorize();
1.111 pPlayer->m_bFakeClient = true;
1.112 @@ -593,7 +630,7 @@
1.113 // This doesn't actually get incremented until OnClientConnect. Fake it to check.
1.114 int newCount = m_PlayersSinceActive + 1;
1.115
1.116 - int userId = engine->GetPlayerUserId(pEntity);
1.117 + int userId = GetPlayerUserId(pEntity);
1.118 #if (SOURCE_ENGINE == SE_ORANGEBOXVALVE || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_LEFT4DEAD2)
1.119 static ConVar *tv_name = icvar->FindVar("tv_name");
1.120 #endif
1.121 @@ -717,10 +754,17 @@
1.122 m_PlayerCount = 0;
1.123 }
1.124
1.125 +#if SOURCE_ENGINE == SE_DOTA
1.126 +void PlayerManager::OnClientDisconnect(int client)
1.127 +{
1.128 + edict_t *pEntity = PEntityOfEntIndex(client);
1.129 +#else
1.130 void PlayerManager::OnClientDisconnect(edict_t *pEntity)
1.131 {
1.132 + int client = IndexOfEdict(pEntity);
1.133 +#endif
1.134 +
1.135 cell_t res;
1.136 - int client = IndexOfEdict(pEntity);
1.137 CPlayer *pPlayer = &m_Players[client];
1.138
1.139 if (pPlayer->IsConnected())
1.140 @@ -755,10 +799,17 @@
1.141 }
1.142 }
1.143
1.144 +#if SOURCE_ENGINE == SE_DOTA
1.145 +void PlayerManager::OnClientDisconnect_Post(int client)
1.146 +{
1.147 + edict_t *pEntity = PEntityOfEntIndex(client);
1.148 +#else
1.149 void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity)
1.150 {
1.151 + int client = IndexOfEdict(pEntity);
1.152 +#endif
1.153 +
1.154 cell_t res;
1.155 - int client = IndexOfEdict(pEntity);
1.156
1.157 m_cldisconnect_post->PushCell(client);
1.158 m_cldisconnect_post->Execute(&res, NULL);
1.159 @@ -790,7 +841,11 @@
1.160 buffer[len] = '\0';
1.161 }
1.162
1.163 +#if SOURCE_ENGINE == SE_DOTA
1.164 + engine->ClientPrintf(IndexOfEdict(e), buffer);
1.165 +#else
1.166 engine->ClientPrintf(e, buffer);
1.167 +#endif
1.168 }
1.169
1.170 void ListExtensionsToClient(CPlayer *player, const CCommand &args)
1.171 @@ -953,15 +1008,22 @@
1.172 }
1.173 }
1.174
1.175 -#if SOURCE_ENGINE >= SE_ORANGEBOX
1.176 +#if SOURCE_ENGINE == SE_DOTA
1.177 +void PlayerManager::OnClientCommand(int client, const CCommand &args)
1.178 +{
1.179 + edict_t *pEntity = PEntityOfEntIndex(client);
1.180 +#elif SOURCE_ENGINE >= SE_ORANGEBOX
1.181 void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args)
1.182 {
1.183 + int client = IndexOfEdict(pEntity);
1.184 #else
1.185 void PlayerManager::OnClientCommand(edict_t *pEntity)
1.186 {
1.187 CCommand args;
1.188 +
1.189 + int client = IndexOfEdict(pEntity);
1.190 #endif
1.191 - int client = IndexOfEdict(pEntity);
1.192 +
1.193 cell_t res = Pl_Continue;
1.194 CPlayer *pPlayer = &m_Players[client];
1.195
1.196 @@ -1070,10 +1132,17 @@
1.197 }
1.198 }
1.199
1.200 +#if SOURCE_ENGINE == SE_DOTA
1.201 +void PlayerManager::OnClientSettingsChanged(int client)
1.202 +{
1.203 + edict_t *pEntity = PEntityOfEntIndex(client);
1.204 +#else
1.205 void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
1.206 {
1.207 + int client = IndexOfEdict(pEntity);
1.208 +#endif
1.209 +
1.210 cell_t res;
1.211 - int client = IndexOfEdict(pEntity);
1.212 CPlayer *pPlayer = &m_Players[client];
1.213
1.214 if (!pPlayer->IsConnected())
1.215 @@ -1193,7 +1262,7 @@
1.216 CPlayer *player = GetPlayerByIndex(client);
1.217 if (player && player->IsConnected())
1.218 {
1.219 - int realUserId = engine->GetPlayerUserId(player->GetEdict());
1.220 + int realUserId = GetPlayerUserId(player->GetEdict());
1.221 if (realUserId == userid)
1.222 {
1.223 return client;
1.224 @@ -1210,7 +1279,7 @@
1.225 {
1.226 continue;
1.227 }
1.228 - if (engine->GetPlayerUserId(player->GetEdict()) == userid)
1.229 + if (GetPlayerUserId(player->GetEdict()) == userid)
1.230 {
1.231 m_UserIdLookUp[userid] = i;
1.232 return i;
1.233 @@ -1324,7 +1393,7 @@
1.234 }
1.235 }
1.236
1.237 - m_UserIdLookUp[engine->GetPlayerUserId(pPlayer->m_pEdict)] = 0;
1.238 + m_UserIdLookUp[GetPlayerUserId(pPlayer->m_pEdict)] = 0;
1.239 pPlayer->Disconnect();
1.240 }
1.241
1.242 @@ -1897,7 +1966,13 @@
1.243 m_SteamAccountID = (atoi(&pAuth[8]) | (atoi(&pAuth[10]) << 1));
1.244 }
1.245 #else
1.246 - unsigned long long *steamId = (unsigned long long *)engine->GetClientSteamID(m_pEdict);
1.247 + unsigned long long *steamId;
1.248 +#if SOURCE_ENGINE == SE_DOTA
1.249 + steamId = (unsigned long long *)engine->GetClientSteamID(m_iIndex);
1.250 +#else
1.251 + steamId = (unsigned long long *)engine->GetClientSteamID(m_pEdict);
1.252 +#endif
1.253 +
1.254 if (steamId)
1.255 {
1.256 m_SteamAccountID = (*steamId & 0xFFFFFFFF);
1.257 @@ -1911,6 +1986,11 @@
1.258 return m_pEdict;
1.259 }
1.260
1.261 +int CPlayer::GetIndex() const
1.262 +{
1.263 + return m_iIndex;
1.264 +}
1.265 +
1.266 bool CPlayer::IsInGame()
1.267 {
1.268 return m_IsInGame && (m_pEdict->GetUnknown() != NULL);
1.269 @@ -1936,7 +2016,11 @@
1.270 #if SOURCE_ENGINE >= SE_ORANGEBOX
1.271 if (g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer())
1.272 {
1.273 +#if SOURCE_ENGINE == SE_DOTA
1.274 + return engine->IsClientFullyAuthenticated(m_iIndex);
1.275 +#else
1.276 return engine->IsClientFullyAuthenticated(m_pEdict);
1.277 +#endif
1.278 }
1.279 #endif
1.280
1.281 @@ -2130,7 +2214,7 @@
1.282 {
1.283 if (!g_Players.CheckSetAdminName(client, this, id))
1.284 {
1.285 - int userid = engine->GetPlayerUserId(m_pEdict);
1.286 + int userid = GetPlayerUserId(m_pEdict);
1.287 g_Timers.CreateTimer(&s_KickPlayerTimer, 0.1f, (void *)userid, 0);
1.288 }
1.289 return;
1.290 @@ -2169,7 +2253,7 @@
1.291 {
1.292 if (m_UserId == -1)
1.293 {
1.294 - m_UserId = engine->GetPlayerUserId(GetEdict());
1.295 + m_UserId = GetPlayerUserId(GetEdict());
1.296 }
1.297
1.298 return m_UserId;