Add IServer::Ban

This commit is contained in:
ChillerDragon 2019-02-04 23:09:14 +01:00
parent 867b0a66ce
commit 03a20d6406
4 changed files with 11 additions and 7 deletions

View file

@ -167,6 +167,8 @@ public:
virtual int GetAuthedState(int ClientID) = 0; virtual int GetAuthedState(int ClientID) = 0;
virtual const char *GetAuthName(int ClientID) = 0; virtual const char *GetAuthName(int ClientID) = 0;
virtual void Kick(int ClientID, const char *pReason) = 0; virtual void Kick(int ClientID, const char *pReason) = 0;
virtual void Ban(int ClientID, int seconds, const char *pReason) = 0;
virtual void DemoRecorder_HandleAutoStart() = 0; virtual void DemoRecorder_HandleAutoStart() = 0;
virtual bool DemoRecorder_IsRecording() = 0; virtual bool DemoRecorder_IsRecording() = 0;

View file

@ -428,6 +428,13 @@ void CServer::Kick(int ClientID, const char *pReason)
m_NetServer.Drop(ClientID, pReason); m_NetServer.Drop(ClientID, pReason);
} }
void CServer::Ban(int ClientID, int seconds, const char *pReason)
{
NETADDR Addr;
GetClientAddr(ClientID, &Addr);
m_NetServer.NetBan()->BanAddr(&Addr, seconds, pReason);
}
/*int CServer::Tick() /*int CServer::Tick()
{ {
return m_CurrentGameTick; return m_CurrentGameTick;

View file

@ -238,6 +238,7 @@ public:
virtual void SetClientScore(int ClientID, int Score); virtual void SetClientScore(int ClientID, int Score);
void Kick(int ClientID, const char *pReason); void Kick(int ClientID, const char *pReason);
void Ban(int ClientID, int seconds, const char *pReason);
void DemoRecorder_HandleAutoStart(); void DemoRecorder_HandleAutoStart();
bool DemoRecorder_IsRecording(); bool DemoRecorder_IsRecording();

View file

@ -1804,13 +1804,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
if(g_Config.m_SvBotVersionNumbers != '\0' && IsBotVersion(Version)) if(g_Config.m_SvBotVersionNumbers != '\0' && IsBotVersion(Version))
{ {
if(g_Config.m_SvBotPunishment) if(g_Config.m_SvBotPunishment)
{ Server()->Ban(ClientID, g_Config.m_SvBotPunishment * 60, "bot client");
char aBuf[128];
NETADDR Addr;
Server()->GetClientAddr(ClientID, &Addr);
str_format(aBuf, sizeof(aBuf), "ban %d %d %s", ClientID, g_Config.m_SvBotPunishment, "bot client");
Console()->ExecuteLine(aBuf);
}
else else
Server()->Kick(ClientID, "bot client"); Server()->Kick(ClientID, "bot client");
} }