From 97b6704a6b587ca99937cc4688ddba4cbed72196 Mon Sep 17 00:00:00 2001 From: Learath Date: Wed, 19 Aug 2020 14:07:55 +0300 Subject: [PATCH] Add ban_region_range and sv_region_name --- src/engine/server/server.cpp | 15 ++++++++++++++- src/engine/server/server.h | 1 + src/engine/shared/config_variables.h | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index 9eaa2054c..c5e00345d 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -147,6 +147,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"); + Console()->Register("ban_region_range", "s[region] s[first ip] s[last ip] ?i[minutes] r[reason]", CFGFLAG_SERVER|CFGFLAG_STORE, ConBanRegionRange, this, "Ban range in a region"); } template @@ -249,13 +250,25 @@ void CServerBan::ConBanExt(IConsole::IResult *pResult, void *pUser) void CServerBan::ConBanRegion(IConsole::IResult *pResult, void *pUser) { const char *pRegion = pResult->GetString(0); - if(str_comp_nocase(pRegion, g_Config.m_SvSqlServerName)) + if(str_comp_nocase(pRegion, g_Config.m_SvRegionName)) return; pResult->RemoveArgument(0); ConBanExt(pResult, pUser); } +void CServerBan::ConBanRegionRange(IConsole::IResult *pResult, void *pUser) +{ + CServerBan *pServerBan = static_cast(pUser); + + const char *pRegion = pResult->GetString(0); + if(str_comp_nocase(pRegion, g_Config.m_SvRegionName)) + return; + + pResult->RemoveArgument(0); + ConBanRange(pResult, static_cast(pServerBan)); +} + void CServer::CClient::Reset() { // reset input diff --git a/src/engine/server/server.h b/src/engine/server/server.h index fa38f2f35..6b29dc747 100644 --- a/src/engine/server/server.h +++ b/src/engine/server/server.h @@ -84,6 +84,7 @@ public: static void ConBanExt(class IConsole::IResult *pResult, void *pUser); static void ConBanRegion(class IConsole::IResult *pResult, void *pUser); + static void ConBanRegionRange(class IConsole::IResult *pResult, void *pUser); }; diff --git a/src/engine/shared/config_variables.h b/src/engine/shared/config_variables.h index f54172a87..6a71a8e63 100644 --- a/src/engine/shared/config_variables.h +++ b/src/engine/shared/config_variables.h @@ -213,6 +213,7 @@ MACRO_CONFIG_INT(SvShotgunBulletSound, sv_shotgun_bullet_sound, 0, 0, 1, CFGFLAG MACRO_CONFIG_INT(SvCheckpointSave, sv_checkpoint_save, 1, 0, 1, CFGFLAG_SERVER, "Whether to save checkpoint times to the score file") MACRO_CONFIG_STR(SvScoreFolder, sv_score_folder, 32, "records", CFGFLAG_SERVER, "Folder to save score files to") +MACRO_CONFIG_STR(SvRegionName, sv_region_name, 5, "UNK", CFGFLAG_SERVER, "Server region. Used for regional bans") MACRO_CONFIG_STR(SvSqlServerName, sv_sql_servername, 5, "UNK", CFGFLAG_SERVER, "SQL Server name that is inserted into record table") MACRO_CONFIG_STR(SvSqlValidServerNames, sv_sql_valid_servernames, 64, "UNK", CFGFLAG_SERVER, "Comma separated list of valid server names for saving a game to ([A-Z][A-Z][A-Z].?") MACRO_CONFIG_INT(SvSaveGames, sv_savegames, 1, 0, 1, CFGFLAG_SERVER, "Enables savegames (/save and /load)")