mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
Admin-Kick-Protection
Add IsAuthed(int ClientID); function. Add kickprotection for admins (Remote Console logged in players) Add Anti-Self-Kick (minor)
This commit is contained in:
parent
979f8d8765
commit
dd19074deb
|
@ -49,6 +49,8 @@ public:
|
||||||
virtual void *SnapNewItem(int Type, int Id, int Size) = 0;
|
virtual void *SnapNewItem(int Type, int Id, int Size) = 0;
|
||||||
|
|
||||||
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
|
||||||
|
|
||||||
|
virtual bool IsAuthed(int ClientID) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class IGameServer : public IInterface
|
class IGameServer : public IInterface
|
||||||
|
|
|
@ -293,6 +293,13 @@ int CServer::Init()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CServer::IsAuthed(int ClientID)
|
||||||
|
{
|
||||||
|
if(m_aClients[ClientID].m_Authed)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int CServer::GetClientInfo(int ClientID, CClientInfo *pInfo)
|
int CServer::GetClientInfo(int ClientID, CClientInfo *pInfo)
|
||||||
{
|
{
|
||||||
dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
|
dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "client_id is not valid");
|
||||||
|
|
|
@ -138,6 +138,7 @@ public:
|
||||||
|
|
||||||
int Init();
|
int Init();
|
||||||
|
|
||||||
|
bool IsAuthed(int ClientID);
|
||||||
int GetClientInfo(int ClientID, CClientInfo *pInfo);
|
int GetClientInfo(int ClientID, CClientInfo *pInfo);
|
||||||
void GetClientIP(int ClientID, char *pIPString, int Size);
|
void GetClientIP(int ClientID, char *pIPString, int Size);
|
||||||
const char *ClientName(int ClientId);
|
const char *ClientName(int ClientId);
|
||||||
|
|
|
@ -647,6 +647,19 @@ void CGameContext::OnMessage(int MsgId, CUnpacker *pUnpacker, int ClientId)
|
||||||
SendChatTarget(ClientId, "Invalid client id to kick");
|
SendChatTarget(ClientId, "Invalid client id to kick");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(KickId == ClientId)
|
||||||
|
{
|
||||||
|
SendChatTarget(ClientId, "You cant kick yourself");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(Server()->IsAuthed(KickId))
|
||||||
|
{
|
||||||
|
SendChatTarget(ClientId, "You cant kick admins");
|
||||||
|
char aBufKick[128];
|
||||||
|
str_format(aBufKick, sizeof(aBufKick), "%s called for vote to kick you", Server()->ClientName(ClientId));
|
||||||
|
SendChatTarget(KickId, aBufKick);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
str_format(aChatmsg, sizeof(aChatmsg), "%s called for vote to kick '%s'", Server()->ClientName(ClientId), Server()->ClientName(KickId));
|
str_format(aChatmsg, sizeof(aChatmsg), "%s called for vote to kick '%s'", Server()->ClientName(ClientId), Server()->ClientName(KickId));
|
||||||
str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId));
|
str_format(aDesc, sizeof(aDesc), "Kick '%s'", Server()->ClientName(KickId));
|
||||||
|
|
Loading…
Reference in a new issue