Remove support for Source 1 Dota 2. (#496)

This commit is contained in:
Nicholas Hastings
2016-04-26 23:18:47 -04:00
parent 6dc602ad7c
commit 40f2512317
52 changed files with 101 additions and 2264 deletions
+28 -149
View File
@@ -65,13 +65,6 @@ List<ICommandTargetProcessor *> target_processors;
ConVar sm_debug_connect("sm_debug_connect", "0", 0, "Log Debug information about potential connection issues.");
#if SOURCE_ENGINE == SE_DOTA
SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, CEntityIndex, const char *, const char *, char *, int);
SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, CEntityIndex, const char *);
SH_DECL_HOOK2_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, CEntityIndex, int);
SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, CEntityIndex, const CCommand &);
SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, CEntityIndex);
#else
SH_DECL_HOOK5(IServerGameClients, ClientConnect, SH_NOATTRIB, 0, bool, edict_t *, const char *, const char *, char *, int);
SH_DECL_HOOK2_void(IServerGameClients, ClientPutInServer, SH_NOATTRIB, 0, edict_t *, const char *);
SH_DECL_HOOK1_void(IServerGameClients, ClientDisconnect, SH_NOATTRIB, 0, edict_t *);
@@ -81,26 +74,20 @@ SH_DECL_HOOK2_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *,
SH_DECL_HOOK1_void(IServerGameClients, ClientCommand, SH_NOATTRIB, 0, edict_t *);
#endif
SH_DECL_HOOK1_void(IServerGameClients, ClientSettingsChanged, SH_NOATTRIB, 0, edict_t *);
#endif // SE_DOTA
#if SOURCE_ENGINE >= SE_EYE && SOURCE_ENGINE != SE_DOTA
#if SOURCE_ENGINE >= SE_EYE
SH_DECL_HOOK2_void(IServerGameClients, ClientCommandKeyValues, SH_NOATTRIB, 0, edict_t *, KeyValues *);
#endif
#if SOURCE_ENGINE == SE_DOTA
SH_DECL_HOOK0_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0);
#else
SH_DECL_HOOK3_void(IServerGameDLL, ServerActivate, SH_NOATTRIB, 0, edict_t *, int, int);
#endif
#if SOURCE_ENGINE >= SE_LEFT4DEAD && SOURCE_ENGINE != SE_DOTA
#if SOURCE_ENGINE >= SE_LEFT4DEAD
SH_DECL_HOOK1_void(IServerGameDLL, ServerHibernationUpdate, SH_NOATTRIB, 0, bool);
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox. +dota
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox.
SH_DECL_HOOK1_void(IServerGameDLL, SetServerHibernation, SH_NOATTRIB, 0, bool);
#endif
#if SOURCE_ENGINE == SE_DOTA
SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
#elif SOURCE_ENGINE >= SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
#elif SOURCE_ENGINE == SE_DARKMESSIAH
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
@@ -177,15 +164,15 @@ void PlayerManager::OnSourceModAllInitialized()
SH_ADD_HOOK(IServerGameClients, ClientDisconnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientDisconnect), false);
SH_ADD_HOOK(IServerGameClients, ClientDisconnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientDisconnect_Post), true);
SH_ADD_HOOK(IServerGameClients, ClientCommand, serverClients, SH_MEMBER(this, &PlayerManager::OnClientCommand), false);
#if SOURCE_ENGINE >= SE_EYE && SOURCE_ENGINE != SE_DOTA
#if SOURCE_ENGINE >= SE_EYE
SH_ADD_HOOK(IServerGameClients, ClientCommandKeyValues, serverClients, SH_MEMBER(this, &PlayerManager::OnClientCommandKeyValues), false);
SH_ADD_HOOK(IServerGameClients, ClientCommandKeyValues, serverClients, SH_MEMBER(this, &PlayerManager::OnClientCommandKeyValues_Post), true);
#endif
SH_ADD_HOOK(IServerGameClients, ClientSettingsChanged, serverClients, SH_MEMBER(this, &PlayerManager::OnClientSettingsChanged), true);
SH_ADD_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true);
#if SOURCE_ENGINE >= SE_LEFT4DEAD && SOURCE_ENGINE != SE_DOTA
#if SOURCE_ENGINE >= SE_LEFT4DEAD
SH_ADD_HOOK(IServerGameDLL, ServerHibernationUpdate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerHibernationUpdate), true);
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox. +dota
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox.
SH_ADD_HOOK(IServerGameDLL, SetServerHibernation, gamedll, SH_MEMBER(this, &PlayerManager::OnServerHibernationUpdate), true);
#endif
@@ -230,15 +217,15 @@ void PlayerManager::OnSourceModShutdown()
SH_REMOVE_HOOK(IServerGameClients, ClientDisconnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientDisconnect), false);
SH_REMOVE_HOOK(IServerGameClients, ClientDisconnect, serverClients, SH_MEMBER(this, &PlayerManager::OnClientDisconnect_Post), true);
SH_REMOVE_HOOK(IServerGameClients, ClientCommand, serverClients, SH_MEMBER(this, &PlayerManager::OnClientCommand), false);
#if SOURCE_ENGINE >= SE_EYE && SOURCE_ENGINE != SE_DOTA
#if SOURCE_ENGINE >= SE_EYE
SH_REMOVE_HOOK(IServerGameClients, ClientCommandKeyValues, serverClients, SH_MEMBER(this, &PlayerManager::OnClientCommandKeyValues), false);
SH_REMOVE_HOOK(IServerGameClients, ClientCommandKeyValues, serverClients, SH_MEMBER(this, &PlayerManager::OnClientCommandKeyValues_Post), true);
#endif
SH_REMOVE_HOOK(IServerGameClients, ClientSettingsChanged, serverClients, SH_MEMBER(this, &PlayerManager::OnClientSettingsChanged), true);
SH_REMOVE_HOOK(IServerGameDLL, ServerActivate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerActivate), true);
#if SOURCE_ENGINE >= SE_LEFT4DEAD && SOURCE_ENGINE != SE_DOTA
#if SOURCE_ENGINE >= SE_LEFT4DEAD
SH_REMOVE_HOOK(IServerGameDLL, ServerHibernationUpdate, gamedll, SH_MEMBER(this, &PlayerManager::OnServerHibernationUpdate), true);
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox. +dota
#elif SOURCE_ENGINE > SE_EYE // 2013/orangebox, but not original orangebox.
SH_REMOVE_HOOK(IServerGameDLL, SetServerHibernation, gamedll, SH_MEMBER(this, &PlayerManager::OnServerHibernationUpdate), true);
#endif
@@ -307,11 +294,7 @@ ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
return ConfigResult_Ignore;
}
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnServerActivate()
#else
void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax)
#endif
{
static ConVar *tv_enable = icvar->FindVar("tv_enable");
#if SOURCE_ENGINE == SE_TF2
@@ -329,11 +312,7 @@ void PlayerManager::OnServerActivate(edict_t *pEdictList, int edictCount, int cl
g_OnMapStarted = true;
m_bServerActivated = true;
#if SOURCE_ENGINE == SE_DOTA
extsys->CallOnCoreMapStart(gpGlobals->pEdicts, gpGlobals->maxEntities, gpGlobals->maxClients);
#else
extsys->CallOnCoreMapStart(pEdictList, edictCount, m_maxClients);
#endif
m_onActivate->Execute(NULL);
m_onActivate2->Execute(NULL);
@@ -499,16 +478,9 @@ void PlayerManager::RunAuthChecks()
}
}
#if SOURCE_ENGINE == SE_DOTA
bool PlayerManager::OnClientConnect(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
int client = index.Get();
edict_t *pEntity = PEntityOfEntIndex(client);
#else
bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
int client = IndexOfEdict(pEntity);
#endif
CPlayer *pPlayer = &m_Players[client];
++m_PlayersSinceActive;
@@ -525,13 +497,8 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
logger->LogMessage("\"%s<%d><%s><>\" was already connected to the server.", pPlayer->GetName(), pPlayer->GetUserId(), pAuth);
}
#if SOURCE_ENGINE == SE_DOTA
OnClientDisconnect(pPlayer->GetIndex(), 0);
OnClientDisconnect_Post(pPlayer->GetIndex(), 0);
#else
OnClientDisconnect(pPlayer->GetEdict());
OnClientDisconnect_Post(pPlayer->GetEdict());
#endif
}
pPlayer->Initialize(pszName, pszAddress, pEntity);
@@ -578,7 +545,7 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
m_AuthQueue[++m_AuthQueue[0]] = client;
}
m_UserIdLookUp[GetPlayerUserId(pEntity)] = client;
m_UserIdLookUp[engine->GetPlayerUserId(pEntity)] = client;
}
else
{
@@ -591,17 +558,9 @@ bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const
return true;
}
#if SOURCE_ENGINE == SE_DOTA
bool PlayerManager::OnClientConnect_Post(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
int client = index.Get();
edict_t *pEntity = PEntityOfEntIndex(client);
#else
bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
int client = IndexOfEdict(pEntity);
#endif
bool orig_value = META_RESULT_ORIG_RET(bool);
CPlayer *pPlayer = &m_Players[client];
@@ -638,18 +597,10 @@ bool PlayerManager::OnClientConnect_Post(edict_t *pEntity, const char *pszName,
return true;
}
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientPutInServer(CEntityIndex index, const char *playername)
{
int client = index.Get();
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername)
{
int client = IndexOfEdict(pEntity);
#endif
cell_t res;
int client = IndexOfEdict(pEntity);
CPlayer *pPlayer = &m_Players[client];
/* If they're not connected, they're a bot */
@@ -682,7 +633,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
// This doesn't actually get incremented until OnClientConnect. Fake it to check.
int newCount = m_PlayersSinceActive + 1;
int userId = GetPlayerUserId(pEntity);
int userId = engine->GetPlayerUserId(pEntity);
#if (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 \
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_LEFT4DEAD2)
static ConVar *tv_name = icvar->FindVar("tv_name");
@@ -722,11 +673,7 @@ void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername
m_SourceTVUserId = userId;
}
#if SOURCE_ENGINE == SE_DOTA
if (!OnClientConnect(client, playername, "127.0.0.1", error, sizeof(error)))
#else
if (!OnClientConnect(pEntity, playername, "127.0.0.1", error, sizeof(error)))
#endif
{
/* :TODO: kick the bot if it's rejected */
return;
@@ -808,13 +755,8 @@ void PlayerManager::OnSourceModLevelEnd()
{
if (m_Players[i].IsConnected())
{
#if SOURCE_ENGINE == SE_DOTA
OnClientDisconnect(m_Players[i].GetIndex(), 0);
OnClientDisconnect_Post(m_Players[i].GetIndex(), 0);
#else
OnClientDisconnect(m_Players[i].GetEdict());
OnClientDisconnect_Post(m_Players[i].GetEdict());
#endif
}
}
m_PlayerCount = 0;
@@ -838,30 +780,17 @@ void PlayerManager::OnServerHibernationUpdate(bool bHibernating)
if (pPlayer->IsSourceTV() || pPlayer->IsReplay())
continue;
#endif
#if SOURCE_ENGINE == SE_DOTA
OnClientDisconnect(m_Players[i].GetIndex(), 0);
OnClientDisconnect_Post(m_Players[i].GetIndex(), 0);
#else
OnClientDisconnect(m_Players[i].GetEdict());
OnClientDisconnect_Post(m_Players[i].GetEdict());
#endif
}
}
}
}
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientDisconnect(CEntityIndex index, int reason)
{
int client = index.Get();
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientDisconnect(edict_t *pEntity)
{
int client = IndexOfEdict(pEntity);
#endif
cell_t res;
int client = IndexOfEdict(pEntity);
CPlayer *pPlayer = &m_Players[client];
if (pPlayer->IsConnected())
@@ -889,16 +818,9 @@ void PlayerManager::OnClientDisconnect(edict_t *pEntity)
}
}
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientDisconnect_Post(CEntityIndex index, int reason)
{
int client = index.Get();
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity)
{
int client = IndexOfEdict(pEntity);
#endif
CPlayer *pPlayer = &m_Players[client];
if (!pPlayer->IsConnected())
{
@@ -1114,24 +1036,17 @@ void ListPluginsToClient(CPlayer *player, const CCommand &args)
}
}
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientCommand(CEntityIndex index, const CCommand &args)
{
int client = index.Get();
edict_t *pEntity = PEntityOfEntIndex(client);
#elif SOURCE_ENGINE >= SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
void PlayerManager::OnClientCommand(edict_t *pEntity, const CCommand &args)
{
int client = IndexOfEdict(pEntity);
#else
void PlayerManager::OnClientCommand(edict_t *pEntity)
{
CCommand args;
int client = IndexOfEdict(pEntity);
#endif
cell_t res = Pl_Continue;
int client = IndexOfEdict(pEntity);
CPlayer *pPlayer = &m_Players[client];
if (!pPlayer->IsConnected())
@@ -1236,7 +1151,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
}
}
#if SOURCE_ENGINE >= SE_EYE && SOURCE_ENGINE != SE_DOTA
#if SOURCE_ENGINE >= SE_EYE
static bool s_LastCCKVAllowed = true;
void PlayerManager::OnClientCommandKeyValues(edict_t *pEntity, KeyValues *pCommand)
@@ -1316,18 +1231,10 @@ void PlayerManager::OnClientCommandKeyValues_Post(edict_t *pEntity, KeyValues *p
}
#endif
#if SOURCE_ENGINE == SE_DOTA
void PlayerManager::OnClientSettingsChanged(CEntityIndex index)
{
int client = index.Get();
edict_t *pEntity = PEntityOfEntIndex(client);
#else
void PlayerManager::OnClientSettingsChanged(edict_t *pEntity)
{
int client = IndexOfEdict(pEntity);
#endif
cell_t res;
int client = IndexOfEdict(pEntity);
CPlayer *pPlayer = &m_Players[client];
if (!pPlayer->IsConnected())
@@ -1447,7 +1354,7 @@ int PlayerManager::GetClientOfUserId(int userid)
CPlayer *player = GetPlayerByIndex(client);
if (player && player->IsConnected())
{
int realUserId = GetPlayerUserId(player->GetEdict());
int realUserId = engine->GetPlayerUserId(player->GetEdict());
if (realUserId == userid)
{
return client;
@@ -1464,7 +1371,7 @@ int PlayerManager::GetClientOfUserId(int userid)
{
continue;
}
if (GetPlayerUserId(player->GetEdict()) == userid)
if (engine->GetPlayerUserId(player->GetEdict()) == userid)
{
m_UserIdLookUp[userid] = i;
return i;
@@ -1570,7 +1477,7 @@ void PlayerManager::InvalidatePlayer(CPlayer *pPlayer)
}
}
m_UserIdLookUp[GetPlayerUserId(pPlayer->m_pEdict)] = 0;
m_UserIdLookUp[engine->GetPlayerUserId(pPlayer->m_pEdict)] = 0;
pPlayer->Disconnect();
}
@@ -1995,10 +1902,7 @@ int PlayerManager::GetClientFromSerial(unsigned int serial)
return 0;
}
#if SOURCE_ENGINE == SE_DOTA
void CmdMaxplayersCallback(const CCommandContext &context, const CCommand &command)
{
#elif SOURCE_ENGINE >= SE_ORANGEBOX
#if SOURCE_ENGINE >= SE_ORANGEBOX
void CmdMaxplayersCallback(const CCommand &command)
{
#else
@@ -2108,13 +2012,7 @@ void CPlayer::UpdateAuthIds()
}
// First cache engine networkid
const char *authstr;
#if SOURCE_ENGINE == SE_DOTA
authstr = engine->GetPlayerNetworkIDString(m_iIndex - 1);
#else
authstr = engine->GetPlayerNetworkIDString(m_pEdict);
#endif
const char *authstr = engine->GetPlayerNetworkIDString(m_pEdict);
if (!authstr)
{
// engine doesn't have the client's auth string just yet, we can't do anything
@@ -2144,13 +2042,7 @@ void CPlayer::UpdateAuthIds()
k_unSteamUserDesktopInstance, k_EUniversePublic, k_EAccountTypeIndividual);
}
#else
const CSteamID *steamId;
#if SOURCE_ENGINE == SE_DOTA
steamId = engine->GetClientSteamID(m_iIndex);
#else
steamId = engine->GetClientSteamID(m_pEdict);
#endif
const CSteamID *steamId = engine->GetClientSteamID(m_pEdict);
if (steamId)
{
m_SteamId = (*steamId);
@@ -2348,11 +2240,7 @@ bool CPlayer::IsAuthStringValidated()
#if SOURCE_ENGINE >= SE_ORANGEBOX
if (!IsFakeClient() && g_Players.m_bAuthstringValidation && !g_HL2.IsLANServer())
{
#if SOURCE_ENGINE == SE_DOTA
return engine->IsClientFullyAuthenticated(m_iIndex);
#else
return engine->IsClientFullyAuthenticated(m_pEdict);
#endif
}
#endif
@@ -2438,12 +2326,7 @@ void CPlayer::Kick(const char *str)
else
{
IClient *pClient = static_cast<IClient *>(pNetChan->GetMsgHandler());
#if SOURCE_ENGINE == SE_DOTA
// Including network_connection.pb.h (and .cpp) is overkill for just this. -p
// Copied from ENetworkDisconnectionReason enum
const int NETWORK_DISCONNECT_KICKED = 39;
pClient->Disconnect(NETWORK_DISCONNECT_KICKED);
#elif SOURCE_ENGINE == SE_CSGO
#if SOURCE_ENGINE == SE_CSGO
pClient->Disconnect(str);
#else
pClient->Disconnect("%s", str);
@@ -2560,7 +2443,7 @@ void CPlayer::DoBasicAdminChecks()
{
if (!g_Players.CheckSetAdminName(client, this, id))
{
int userid = GetPlayerUserId(m_pEdict);
int userid = engine->GetPlayerUserId(m_pEdict);
g_Timers.CreateTimer(&s_KickPlayerTimer, 0.1f, (void *)userid, 0);
}
return;
@@ -2599,7 +2482,7 @@ int CPlayer::GetUserId()
{
if (m_UserId == -1)
{
m_UserId = GetPlayerUserId(GetEdict());
m_UserId = engine->GetPlayerUserId(GetEdict());
}
return m_UserId;
@@ -2675,9 +2558,5 @@ void CPlayer::PrintToConsole(const char *pMsg)
return;
}
#if SOURCE_ENGINE == SE_DOTA
engine->ClientPrintf(m_iIndex, pMsg);
#else
engine->ClientPrintf(m_pEdict, pMsg);
#endif
}