Add ban_region_range and sv_region_name

This commit is contained in:
Learath 2020-08-19 14:07:55 +03:00
parent 6a936602aa
commit 97b6704a6b
3 changed files with 16 additions and 1 deletions

View file

@ -147,6 +147,7 @@ void CServerBan::InitServerBan(IConsole *pConsole, IStorage *pStorage, CServer *
// overwrites base command, todo: improve this // 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", "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", "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<class T> template<class T>
@ -249,13 +250,25 @@ void CServerBan::ConBanExt(IConsole::IResult *pResult, void *pUser)
void CServerBan::ConBanRegion(IConsole::IResult *pResult, void *pUser) void CServerBan::ConBanRegion(IConsole::IResult *pResult, void *pUser)
{ {
const char *pRegion = pResult->GetString(0); 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; return;
pResult->RemoveArgument(0); pResult->RemoveArgument(0);
ConBanExt(pResult, pUser); ConBanExt(pResult, pUser);
} }
void CServerBan::ConBanRegionRange(IConsole::IResult *pResult, void *pUser)
{
CServerBan *pServerBan = static_cast<CServerBan *>(pUser);
const char *pRegion = pResult->GetString(0);
if(str_comp_nocase(pRegion, g_Config.m_SvRegionName))
return;
pResult->RemoveArgument(0);
ConBanRange(pResult, static_cast<CNetBan *>(pServerBan));
}
void CServer::CClient::Reset() void CServer::CClient::Reset()
{ {
// reset input // reset input

View file

@ -84,6 +84,7 @@ public:
static void ConBanExt(class IConsole::IResult *pResult, void *pUser); static void ConBanExt(class IConsole::IResult *pResult, void *pUser);
static void ConBanRegion(class IConsole::IResult *pResult, void *pUser); static void ConBanRegion(class IConsole::IResult *pResult, void *pUser);
static void ConBanRegionRange(class IConsole::IResult *pResult, void *pUser);
}; };

View file

@ -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_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(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(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_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)") MACRO_CONFIG_INT(SvSaveGames, sv_savegames, 1, 0, 1, CFGFLAG_SERVER, "Enables savegames (/save and /load)")