mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #5375
5375: Paginate bans (partially fixes #3691) r=Learath2 a=def- 20 elements per page, we have too many bot bans ![Screenshot 2022-06-08 at 23 53 16](https://user-images.githubusercontent.com/2335377/172724048-70d99f57-4e3c-451a-ada3-96affdf7cd6c.png) ## Checklist - [x] Tested the change ingame - [x] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: Dennis Felsing <dennis@felsin9.de>
This commit is contained in:
commit
16b8806302
|
@ -4241,7 +4241,7 @@ void CClient::RegisterCommands()
|
||||||
m_pConsole->Register("kick", "i[id] ?r[reason]", CFGFLAG_SERVER, 0, 0, "Kick player with specified id for any reason");
|
m_pConsole->Register("kick", "i[id] ?r[reason]", CFGFLAG_SERVER, 0, 0, "Kick player with specified id for any reason");
|
||||||
m_pConsole->Register("ban", "s[ip|id] ?i[minutes] r[reason]", CFGFLAG_SERVER, 0, 0, "Ban player with ip/id for x minutes for any reason");
|
m_pConsole->Register("ban", "s[ip|id] ?i[minutes] r[reason]", CFGFLAG_SERVER, 0, 0, "Ban player with ip/id for x minutes for any reason");
|
||||||
m_pConsole->Register("unban", "r[ip]", CFGFLAG_SERVER, 0, 0, "Unban ip");
|
m_pConsole->Register("unban", "r[ip]", CFGFLAG_SERVER, 0, 0, "Unban ip");
|
||||||
m_pConsole->Register("bans", "", CFGFLAG_SERVER, 0, 0, "Show banlist");
|
m_pConsole->Register("bans", "?i[page]", CFGFLAG_SERVER, 0, 0, "Show banlist (page 0 by default, 20 entries per page)");
|
||||||
m_pConsole->Register("status", "?r[name]", CFGFLAG_SERVER, 0, 0, "List players containing name or all players");
|
m_pConsole->Register("status", "?r[name]", CFGFLAG_SERVER, 0, 0, "List players containing name or all players");
|
||||||
m_pConsole->Register("shutdown", "", CFGFLAG_SERVER, 0, 0, "Shut down");
|
m_pConsole->Register("shutdown", "", CFGFLAG_SERVER, 0, 0, "Shut down");
|
||||||
m_pConsole->Register("record", "r[file]", CFGFLAG_SERVER, 0, 0, "Record to a file");
|
m_pConsole->Register("record", "r[file]", CFGFLAG_SERVER, 0, 0, "Record to a file");
|
||||||
|
|
|
@ -309,7 +309,7 @@ void CNetBan::Init(IConsole *pConsole, IStorage *pStorage)
|
||||||
Console()->Register("unban", "s[ip|entry]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConUnban, this, "Unban ip/banlist entry");
|
Console()->Register("unban", "s[ip|entry]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConUnban, this, "Unban ip/banlist entry");
|
||||||
Console()->Register("unban_range", "s[first ip] s[last ip]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConUnbanRange, this, "Unban ip range");
|
Console()->Register("unban_range", "s[first ip] s[last ip]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConUnbanRange, this, "Unban ip range");
|
||||||
Console()->Register("unban_all", "", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConUnbanAll, this, "Unban all entries");
|
Console()->Register("unban_all", "", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConUnbanAll, this, "Unban all entries");
|
||||||
Console()->Register("bans", "", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConBans, this, "Show banlist");
|
Console()->Register("bans", "?i[page]", CFGFLAG_SERVER | CFGFLAG_MASTER, ConBans, this, "Show banlist (page 0 by default, 20 entries per page)");
|
||||||
Console()->Register("bans_save", "s[file]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConBansSave, this, "Save banlist in a file");
|
Console()->Register("bans_save", "s[file]", CFGFLAG_SERVER | CFGFLAG_MASTER | CFGFLAG_STORE, ConBansSave, this, "Save banlist in a file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,16 +503,28 @@ void CNetBan::ConBans(IConsole::IResult *pResult, void *pUser)
|
||||||
{
|
{
|
||||||
CNetBan *pThis = static_cast<CNetBan *>(pUser);
|
CNetBan *pThis = static_cast<CNetBan *>(pUser);
|
||||||
|
|
||||||
|
int Page = pResult->NumArguments() > 0 ? pResult->GetInteger(0) : 0;
|
||||||
|
static const int EntriesPerPage = 20;
|
||||||
|
|
||||||
int Count = 0;
|
int Count = 0;
|
||||||
char aBuf[256], aMsg[256];
|
char aBuf[256], aMsg[256];
|
||||||
for(CBanAddr *pBan = pThis->m_BanAddrPool.First(); pBan; pBan = pBan->m_pNext)
|
int i = 0;
|
||||||
|
for(CBanAddr *pBan = pThis->m_BanAddrPool.First(); pBan; pBan = pBan->m_pNext, i++)
|
||||||
{
|
{
|
||||||
|
if(i < Page * EntriesPerPage || i >= (Page + 1) * EntriesPerPage)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pThis->MakeBanInfo(pBan, aBuf, sizeof(aBuf), MSGTYPE_LIST);
|
pThis->MakeBanInfo(pBan, aBuf, sizeof(aBuf), MSGTYPE_LIST);
|
||||||
str_format(aMsg, sizeof(aMsg), "#%i %s", Count++, aBuf);
|
str_format(aMsg, sizeof(aMsg), "#%i %s", Count++, aBuf);
|
||||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", aMsg);
|
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", aMsg);
|
||||||
}
|
}
|
||||||
for(CBanRange *pBan = pThis->m_BanRangePool.First(); pBan; pBan = pBan->m_pNext)
|
for(CBanRange *pBan = pThis->m_BanRangePool.First(); pBan; pBan = pBan->m_pNext, i++)
|
||||||
{
|
{
|
||||||
|
if(i < Page * EntriesPerPage || i >= (Page + 1) * EntriesPerPage)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
pThis->MakeBanInfo(pBan, aBuf, sizeof(aBuf), MSGTYPE_LIST);
|
pThis->MakeBanInfo(pBan, aBuf, sizeof(aBuf), MSGTYPE_LIST);
|
||||||
str_format(aMsg, sizeof(aMsg), "#%i %s", Count++, aBuf);
|
str_format(aMsg, sizeof(aMsg), "#%i %s", Count++, aBuf);
|
||||||
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", aMsg);
|
pThis->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", aMsg);
|
||||||
|
|
Loading…
Reference in a new issue