Fix crash on autoban unsupported client

This commit is contained in:
fokkonaut 2021-02-11 12:42:26 +01:00
parent 1dd7c0b65c
commit c79bb91b16
2 changed files with 19 additions and 14 deletions

View file

@ -1246,13 +1246,6 @@ void CGameContext::OnClientEnter(int ClientID)
if(!Server()->ClientPrevIngame(ClientID))
{
IServer::CClientInfo Info;
Server()->GetClientInfo(ClientID, &Info);
if(Info.m_GotDDNetVersion)
{
OnClientDDNetVersionKnown(ClientID);
}
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientID), m_pController->GetTeamName(m_apPlayers[ClientID]->GetTeam()));
SendChat(-1, CGameContext::CHAT_ALL, aBuf, -1, CHAT_SIX);
@ -1266,6 +1259,14 @@ void CGameContext::OnClientEnter(int ClientID)
Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
IServer::CClientInfo Info;
Server()->GetClientInfo(ClientID, &Info);
if(Info.m_GotDDNetVersion)
{
if(OnClientDDNetVersionKnown(ClientID))
return; // kicked
}
if(g_Config.m_SvShowOthersDefault > 0)
{
if(g_Config.m_SvShowOthers)
@ -1440,7 +1441,7 @@ void CGameContext::OnClientEngineDrop(int ClientID, const char *pReason)
}
}
void CGameContext::OnClientDDNetVersionKnown(int ClientID)
bool CGameContext::OnClientDDNetVersionKnown(int ClientID)
{
IServer::CClientInfo Info;
Server()->GetClientInfo(ClientID, &Info);
@ -1459,6 +1460,13 @@ void CGameContext::OnClientDDNetVersionKnown(int ClientID)
}
}
// Autoban known bot versions.
if(g_Config.m_SvBannedVersions[0] != '\0' && IsVersionBanned(ClientVersion))
{
Server()->Kick(ClientID, "unsupported client");
return true;
}
CPlayer *pPlayer = m_apPlayers[ClientID];
if(ClientVersion >= VERSION_DDNET_GAMETICK)
pPlayer->m_TimerType = g_Config.m_SvDefaultTimerType;
@ -1479,11 +1487,8 @@ void CGameContext::OnClientDDNetVersionKnown(int ClientID)
// Tell known bot clients that they're botting and we know it.
if(((ClientVersion >= 15 && ClientVersion < 100) || ClientVersion == 502) && g_Config.m_SvClientSuggestionBot[0] != '\0')
SendBroadcast(g_Config.m_SvClientSuggestionBot, ClientID);
// Autoban known bot versions.
if(g_Config.m_SvBannedVersions[0] != '\0' && IsVersionBanned(ClientVersion))
{
Server()->Kick(ClientID, "unsupported client");
}
return false;
}
void *CGameContext::PreProcessMsg(int *MsgID, CUnpacker *pUnpacker, int ClientID)

View file

@ -273,7 +273,7 @@ public:
virtual const char *NetVersion();
// DDRace
void OnClientDDNetVersionKnown(int ClientID);
bool OnClientDDNetVersionKnown(int ClientID);
virtual void FillAntibot(CAntibotRoundData *pData);
int ProcessSpamProtection(int ClientID);
int GetDDRaceTeam(int ClientID);