mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge branch 'DDRace' of github.com:GreYFoX/teeworlds into DDRace
This commit is contained in:
commit
f5f706ca6d
|
@ -1444,7 +1444,7 @@ void CServer::ConBan(IConsole::IResult *pResult, void *pUser)
|
|||
const char *pReason = "No reason given";
|
||||
|
||||
if(pResult->NumArguments() > 1)
|
||||
Minutes = max(0, pResult->GetInteger(1));
|
||||
Minutes = min(max(0, pResult->GetInteger(1)), 1000000); // todo: fix this in year 2035
|
||||
|
||||
if(pResult->NumArguments() > 2)
|
||||
pReason = pResult->GetString(2);
|
||||
|
|
|
@ -174,15 +174,11 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason)
|
|||
if(Seconds)
|
||||
Stamp = time_timestamp() + Seconds;
|
||||
|
||||
// search to see if it already exists
|
||||
// search to remove it if it already exists
|
||||
pBan = m_aBans[IpHash];
|
||||
MACRO_LIST_FIND(pBan, m_pHashNext, net_addr_comp(&pBan->m_Info.m_Addr, &Addr) == 0);
|
||||
if(pBan)
|
||||
{
|
||||
// adjust the ban
|
||||
pBan->m_Info.m_Expires = Stamp;
|
||||
return 0;
|
||||
}
|
||||
BanRemoveByObject(pBan);
|
||||
|
||||
if(!m_BanPool_FirstFree)
|
||||
return -1;
|
||||
|
@ -206,14 +202,19 @@ int CNetServer::BanAdd(NETADDR Addr, int Seconds, const char *pReason)
|
|||
CBan *pInsertAfter = m_BanPool_FirstUsed;
|
||||
MACRO_LIST_FIND(pInsertAfter, m_pNext, Stamp < pInsertAfter->m_Info.m_Expires);
|
||||
|
||||
if(pInsertAfter)
|
||||
if(pInsertAfter && Stamp != -1)
|
||||
pInsertAfter = pInsertAfter->m_pPrev;
|
||||
else
|
||||
{
|
||||
// add to last
|
||||
pInsertAfter = m_BanPool_FirstUsed;
|
||||
while(pInsertAfter->m_pNext)
|
||||
pInsertAfter = pInsertAfter->m_pNext;
|
||||
if (m_BanPool_FirstUsed->m_Info.m_Expires == -1)
|
||||
pInsertAfter = 0;
|
||||
else
|
||||
{
|
||||
pInsertAfter = m_BanPool_FirstUsed;
|
||||
while(pInsertAfter->m_pNext && pInsertAfter->m_pNext->m_Info.m_Expires != -1)
|
||||
pInsertAfter = pInsertAfter->m_pNext;
|
||||
}
|
||||
}
|
||||
|
||||
if(pInsertAfter)
|
||||
|
|
Loading…
Reference in a new issue