diff --git a/src/engine/console.h b/src/engine/console.h index f33ec45bc..dace3fac1 100644 --- a/src/engine/console.h +++ b/src/engine/console.h @@ -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; diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index cdf4cba1a..9eaa2054c 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -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 @@ -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() { diff --git a/src/engine/server/server.h b/src/engine/server/server.h index c68bb1f9b..fa38f2f35 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -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); }; diff --git a/src/engine/shared/console.h b/src/engine/shared/console.h index 5ffb247f0..8ac40736c 100644 --- a/src/engine/shared/console.h +++ b/src/engine/shared/console.h @@ -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