Merge branch 'DDRace' of github.com:GreYFoX/teeworlds into DDRace

This commit is contained in:
Shereef Marzouk 2011-12-14 17:02:45 +02:00
commit f5f706ca6d
2 changed files with 12 additions and 11 deletions

View file

@ -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);

View file

@ -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)