mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-05 15:48:19 +00:00
Add ban_region
This commit is contained in:
parent
c59ba2acd0
commit
6a936602aa
|
@ -48,6 +48,8 @@ public:
|
|||
virtual const char *GetString(unsigned Index) = 0;
|
||||
virtual ColorHSLA GetColor(unsigned Index, bool Light) = 0;
|
||||
|
||||
virtual void RemoveArgument(unsigned Index) = 0;
|
||||
|
||||
int NumArguments() const { return m_NumArgs; }
|
||||
int m_ClientID;
|
||||
|
||||
|
|
|
@ -146,6 +146,7 @@ void CServerBan::InitServerBan(IConsole *pConsole, IStorage *pStorage, CServer *
|
|||
|
||||
// overwrites base command, todo: improve this
|
||||
Console()->Register("ban", "s[ip|id] ?i[minutes] r[reason]", CFGFLAG_SERVER|CFGFLAG_STORE, ConBanExt, this, "Ban player with ip/client id for x minutes for any reason");
|
||||
Console()->Register("ban_region", "s[region] s[ip|id] ?i[minutes] r[reason]", CFGFLAG_SERVER|CFGFLAG_STORE, ConBanRegion, this, "Ban player in a region");
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
@ -245,6 +246,15 @@ void CServerBan::ConBanExt(IConsole::IResult *pResult, void *pUser)
|
|||
ConBan(pResult, pUser);
|
||||
}
|
||||
|
||||
void CServerBan::ConBanRegion(IConsole::IResult *pResult, void *pUser)
|
||||
{
|
||||
const char *pRegion = pResult->GetString(0);
|
||||
if(str_comp_nocase(pRegion, g_Config.m_SvSqlServerName))
|
||||
return;
|
||||
|
||||
pResult->RemoveArgument(0);
|
||||
ConBanExt(pResult, pUser);
|
||||
}
|
||||
|
||||
void CServer::CClient::Reset()
|
||||
{
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
virtual int BanRange(const CNetRange *pRange, int Seconds, const char *pReason);
|
||||
|
||||
static void ConBanExt(class IConsole::IResult *pResult, void *pUser);
|
||||
static void ConBanRegion(class IConsole::IResult *pResult, void *pUser);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -121,6 +121,15 @@ class CConsole : public IConsole
|
|||
virtual float GetFloat(unsigned Index);
|
||||
virtual ColorHSLA GetColor(unsigned Index, bool Light);
|
||||
|
||||
virtual void RemoveArgument(unsigned Index)
|
||||
{
|
||||
dbg_assert(Index < m_NumArgs, "invalid argument index");
|
||||
for(unsigned i = Index; i < m_NumArgs - 1; i++)
|
||||
m_apArgs[i] = m_apArgs[i + 1];
|
||||
|
||||
m_apArgs[m_NumArgs--] = 0;
|
||||
}
|
||||
|
||||
// DDRace
|
||||
|
||||
enum
|
||||
|
|
Loading…
Reference in a new issue