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

Method Update

src/engine/client/serverbrowser.cpp:1274–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1272}
1273
1274void CServerBrowser::Update()
1275{
1276 int64_t Timeout = time_freq();
1277 int64_t Now = time_get();
1278
1279 const char *pHttpBestUrl;
1280 if(!m_pHttp->GetBestUrl(&pHttpBestUrl) && pHttpBestUrl != m_pHttpPrevBestUrl)
1281 {
1282 str_copy(g_Config.m_BrCachedBestServerinfoUrl, pHttpBestUrl);
1283 m_pHttpPrevBestUrl = pHttpBestUrl;
1284 }
1285
1286 m_pHttp->Update();
1287
1288 if(m_ServerlistType != TYPE_LAN && m_RefreshingHttp && !m_pHttp->IsRefreshing())
1289 {
1290 m_RefreshingHttp = false;
1291 CleanUp();
1292 UpdateFromHttp();
1293 // TODO: move this somewhere else
1294 Sort();
1295 return;
1296 }
1297
1298 {
1299 CServerEntry *pEntry = m_pFirstReqServer;
1300 int Count = 0;
1301 while(true)
1302 {
1303 if(!pEntry) // no more entries
1304 break;
1305 if(pEntry->m_RequestTime && pEntry->m_RequestTime + Timeout < Now)
1306 {
1307 pEntry = pEntry->m_pNextReq;
1308 continue;
1309 }
1310 // no more than 10 concurrent requests
1311 if(Count == m_CurrentMaxRequests)
1312 break;
1313
1314 if(pEntry->m_RequestTime == 0)
1315 {
1316 RequestImpl(pEntry->m_Info.m_aAddresses[0], pEntry, nullptr, nullptr, false);
1317 }
1318
1319 Count++;
1320 pEntry = pEntry->m_pNextReq;
1321 }
1322
1323 if(m_pFirstReqServer && Count == 0 && m_CurrentMaxRequests > 1) //NO More current Server Requests
1324 {
1325 //reset old ones
1326 pEntry = m_pFirstReqServer;
1327 while(true)
1328 {
1329 if(!pEntry) // no more entries
1330 break;
1331 pEntry->m_RequestTime = 0;

Callers

nothing calls this directly

Calls 15

time_freqFunction · 0.85
time_getFunction · 0.85
str_compFunction · 0.85
IsPingAllowedMethod · 0.80
GetCurrentTypeMethod · 0.80
DDNetInfoSha256Method · 0.80
CurrentCommunitiesMethod · 0.80
beginMethod · 0.80
endMethod · 0.80
FlagIdMethod · 0.80
HasRanksMethod · 0.80

Tested by

no test coverage detected