Better Refreshing

Conflicts:
	src/engine/client/client.cpp
	src/engine/client/serverbrowser.cpp
	src/engine/client/serverbrowser.h
	src/engine/masterserver.h
	src/engine/shared/masterserver.cpp
This commit is contained in:
Patrick Rathje 2013-12-31 03:18:37 +01:00 committed by def
parent 020bb16f54
commit 4c080fe137
4 changed files with 20 additions and 25 deletions

View file

@ -924,7 +924,7 @@ void CClient::ProcessConnlessPacket(CNetChunk *pPacket)
m_MapChecker.AddMaplist((CMapVersion *)((char*)pPacket->m_pData+sizeof(VERSIONSRV_MAPLIST)), Num);
}
}
//server count from master server
if(pPacket->m_DataSize == (int) sizeof(SERVERBROWSE_COUNT) + 2 && mem_comp(pPacket->m_pData, SERVERBROWSE_COUNT, sizeof(SERVERBROWSE_COUNT)) == 0)
{

View file

@ -479,7 +479,7 @@ void CServerBrowser::Refresh(int Type)
m_pFirstReqServer = 0;
m_pLastReqServer = 0;
m_NumRequests = 0;
m_CurrentMaxRequests = (1<<g_Config.m_BrMaxRequests);
m_CurrentMaxRequests = g_Config.m_BrMaxRequests;
// next token
m_CurrentToken = (m_CurrentToken+1)&0xff;
@ -593,7 +593,7 @@ void CServerBrowser::Update(bool ForceResort)
int64 Now = time_get();
int Count;
CServerEntry *pEntry, *pNext;
// do server list requests
if(m_NeedRefresh && !m_pMasterServer->IsRefreshing())
{
@ -617,8 +617,11 @@ void CServerBrowser::Update(bool ForceResort)
Addr = m_pMasterServer->GetAddr(i);
m_pMasterServer->SetCount(i, -1);
Packet.m_Address = Addr;
m_pNetClient->Send(&Packet);
dbg_msg("send to", "%d", i);
m_pNetClient->Send(&Packet);
if(g_Config.m_Debug)
{
dbg_msg("client_srvbrowse", "Count-Request sent to %d", i);
}
}
}
@ -657,29 +660,16 @@ void CServerBrowser::Update(bool ForceResort)
m_pNetClient->Send(&Packet);
}
if(g_Config.m_Debug)
m_pConsole->Print(IConsole::OUTPUT_LEVEL_DEBUG, "client_srvbrowse", "requesting server list");
dbg_msg("msg", "%d", m_MasterServerCount);
{
dbg_msg("client_srvbrowse", "ServerCount: %d, requesting server list", m_MasterServerCount);
}
m_LastPacketTick = 0;
}
}
if(m_MasterServerCount > m_NumRequests + m_LastPacketTick)
{
++m_LastPacketTick;
return; //wait for more packets
}
pEntry = m_pFirstReqServer;
Count = 0;
while(1)
@ -718,7 +708,9 @@ void CServerBrowser::Update(bool ForceResort)
}
//update max-requests
m_CurrentMaxRequests = (m_CurrentMaxRequests>>1);
m_CurrentMaxRequests = m_CurrentMaxRequests/2;
if(m_CurrentMaxRequests < 1)
m_CurrentMaxRequests = 1;
}
else if(Count == 0 && m_CurrentMaxRequests == 1) //we reached the limit, just release all left requests. IF a server sends us a packet, a new request will be added automatically, so we can delete all
{

View file

@ -74,8 +74,11 @@ private:
int m_NumRequests;
int m_MasterServerCount;
//used instead of g_Config.br_max_requests to get more servers
int m_CurrentMaxRequests;
int m_LastPacketTick;
int m_NeedRefresh;
int m_NumSortedServers;

View file

@ -24,7 +24,7 @@ public:
virtual void Update() = 0;
virtual int IsRefreshing() = 0;
virtual NETADDR GetAddr(int Index) = 0;
virtual void SetCount(int Index, int Count) = 0;
virtual void SetCount(int Index, int Count) = 0;
virtual int GetCount(int Index) = 0;
virtual const char *GetName(int Index) = 0;
virtual bool IsValid(int Index) = 0;