mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Fix crash on autoban unsupported client
This commit is contained in:
parent
1dd7c0b65c
commit
c79bb91b16
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue