diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index bb47c52a5..f7167c511 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -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); diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 6ac266d56..26c3d92c9 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -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)