mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Add IServer::Ban
This commit is contained in:
parent
867b0a66ce
commit
03a20d6406
|
@ -167,6 +167,8 @@ public:
|
|||
virtual int GetAuthedState(int ClientID) = 0;
|
||||
virtual const char *GetAuthName(int ClientID) = 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 bool DemoRecorder_IsRecording() = 0;
|
||||
|
|
|
@ -428,6 +428,13 @@ void CServer::Kick(int ClientID, const char *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()
|
||||
{
|
||||
return m_CurrentGameTick;
|
||||
|
|
|
@ -238,6 +238,7 @@ public:
|
|||
virtual void SetClientScore(int ClientID, int Score);
|
||||
|
||||
void Kick(int ClientID, const char *pReason);
|
||||
void Ban(int ClientID, int seconds, const char *pReason);
|
||||
|
||||
void DemoRecorder_HandleAutoStart();
|
||||
bool DemoRecorder_IsRecording();
|
||||
|
|
|
@ -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_SvBotPunishment)
|
||||
{
|
||||
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);
|
||||
}
|
||||
Server()->Ban(ClientID, g_Config.m_SvBotPunishment * 60, "bot client");
|
||||
else
|
||||
Server()->Kick(ClientID, "bot client");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue