MCPcopy Create free account
hub / github.com/ddnet/ddnet / UnbanByIndex

Method UnbanByIndex

src/engine/shared/netban.cpp:342–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342int CNetBan::UnbanByIndex(int Index)
343{
344 int Result;
345 char aBuf[256];
346 CBanAddr *pBan = m_BanAddrPool.Get(Index);
347 if(pBan)
348 {
349 NetToString(&pBan->m_Data, aBuf, sizeof(aBuf));
350 Result = m_BanAddrPool.Remove(pBan);
351 }
352 else
353 {
354 CBanRange *pBanRange = m_BanRangePool.Get(Index - m_BanAddrPool.Num());
355 if(pBanRange)
356 {
357 NetToString(&pBanRange->m_Data, aBuf, sizeof(aBuf));
358 Result = m_BanRangePool.Remove(pBanRange);
359 }
360 else
361 {
362 Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", "unban failed (invalid index)");
363 return -1;
364 }
365 }
366
367 char aMsg[256];
368 str_format(aMsg, sizeof(aMsg), "unbanned index %i (%s)", Index, aBuf);
369 Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "net_ban", aMsg);
370 return Result;
371}
372
373bool CNetBan::IsBanned(const NETADDR *pOrigAddr, char *pBuf, unsigned BufferSize) const
374{

Callers 1

ConUnbanMethod · 0.80

Calls 5

str_formatFunction · 0.85
GetMethod · 0.45
RemoveMethod · 0.45
NumMethod · 0.45
PrintMethod · 0.45

Tested by

no test coverage detected