mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Use str_in_list, generalize further
This commit is contained in:
parent
5d99746cc1
commit
0086452757
|
@ -359,7 +359,7 @@ MACRO_CONFIG_INT(SvSoloServer, sv_solo_server, 0, 0, 1, CFGFLAG_SERVER|CFGFLAG_G
|
|||
MACRO_CONFIG_STR(SvClientSuggestion, sv_client_suggestion, 128, "Get DDNet client from DDNet.tw to use all features on DDNet!", CFGFLAG_SERVER, "Broadcast to display to players without DDNet client")
|
||||
MACRO_CONFIG_STR(SvClientSuggestionOld, sv_client_suggestion_old, 128, "Your DDNet client is old, update it on DDNet.tw!", CFGFLAG_SERVER, "Broadcast to display to players with an old version of DDNet client")
|
||||
MACRO_CONFIG_STR(SvClientSuggestionBot, sv_client_suggestion_bot, 128, "Your client has bots and can be remotely controlled!\nPlease use another client like DDNet client from DDNet.tw", CFGFLAG_SERVER, "Broadcast to display to players with a known botting client")
|
||||
MACRO_CONFIG_STR(SvBotVersions, sv_bot_versions, 128, "", CFGFLAG_SERVER, "Comma seperated list of known bot clients to be kicked on join")
|
||||
MACRO_CONFIG_STR(SvBannedVersions, sv_banned_versions, 128, "", CFGFLAG_SERVER, "Comma seperated list of banned clients to be kicked on join")
|
||||
|
||||
// netlimit
|
||||
MACRO_CONFIG_INT(SvNetlimit, sv_netlimit, 0, 0, 10000, CFGFLAG_SERVER, "Netlimit: Maximum amount of traffic a client is allowed to use (in kb/s)")
|
||||
|
|
|
@ -1801,7 +1801,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
if (((Version >= 15 && Version < 100) || Version == 502) && g_Config.m_SvClientSuggestionBot[0] != '\0')
|
||||
SendBroadcast(g_Config.m_SvClientSuggestionBot, ClientID);
|
||||
//autoban known bot versions
|
||||
if(g_Config.m_SvBotVersions[0] != '\0' && IsBotVersion(Version))
|
||||
if(g_Config.m_SvBannedVersions[0] != '\0' && IsVersionBanned(Version))
|
||||
{
|
||||
Server()->Kick(ClientID, "unsupported client");
|
||||
}
|
||||
|
@ -3555,23 +3555,12 @@ void CGameContext::Converse(int ClientID, char *pStr)
|
|||
}
|
||||
}
|
||||
|
||||
bool CGameContext::IsBotVersion(int Version)
|
||||
bool CGameContext::IsVersionBanned(int Version)
|
||||
{
|
||||
char aVersion[16];
|
||||
str_format(aVersion, sizeof(aVersion), "%d", Version);
|
||||
char aVersions[sizeof(g_Config.m_SvBotVersions)];
|
||||
str_copy(aVersions, g_Config.m_SvBotVersions, sizeof(aVersions));
|
||||
char *p = strtok(aVersions, ",");;
|
||||
|
||||
while(p)
|
||||
{
|
||||
if(!str_comp(p, aVersion))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
p = strtok(NULL, ",");
|
||||
}
|
||||
return false;
|
||||
return str_in_list(g_Config.m_SvBannedVersions, ",", aVersion);
|
||||
}
|
||||
|
||||
void CGameContext::List(int ClientID, const char *pFilter)
|
||||
|
|
|
@ -389,7 +389,7 @@ private:
|
|||
void Whisper(int ClientID, char *pStr);
|
||||
void WhisperID(int ClientID, int VictimID, char *pMessage);
|
||||
void Converse(int ClientID, char *pStr);
|
||||
bool IsBotVersion(int Version);
|
||||
bool IsVersionBanned(int Version);
|
||||
|
||||
public:
|
||||
CLayers *Layers() { return &m_Layers; }
|
||||
|
|
Loading…
Reference in a new issue