Skip to content

Commit

Permalink
Faster ban search in ServerGuard
Browse files Browse the repository at this point in the history
  • Loading branch information
bear101 committed Oct 25, 2023
1 parent 83d3e3e commit 042e7e8
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Library/TeamTalkLib/bin/ttsrv/ServerXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,13 +1244,16 @@ namespace teamtalk{

bool ServerXML::IsUserBanned(const BannedUser& ban)
{
int c = GetUserBanCount();
for(int i=0;i<c;i++)
TiXmlElement* item = GetServerBansElement();
if (item)
{
BannedUser tmp;
if(GetUserBan(i, tmp) && tmp.Match(ban))
for(TiXmlElement* child = item->FirstChildElement("serverban");
child;
child = child->NextSiblingElement("serverban"))
{
return true;
BannedUser tmp;
if (GetUserBan(*child, tmp) && tmp.Match(ban))
return true;
}
}
return false;
Expand All @@ -1266,11 +1269,17 @@ namespace teamtalk{
std::vector<BannedUser> ServerXML::GetUserBans()
{
std::vector<BannedUser> result;
for(int i=0;i<GetUserBanCount();i++)
TiXmlElement* item = GetServerBansElement();
if (item)
{
BannedUser ban;
GetUserBan(i, ban);
result.push_back(ban);
for(TiXmlElement* child = item->FirstChildElement("serverban");
child;
child = child->NextSiblingElement("serverban"))
{
BannedUser tmp;
GetUserBan(*child, tmp);
result.push_back(tmp);
}
}
return result;
}
Expand Down

0 comments on commit 042e7e8

Please sign in to comment.