| 418 | } |
| 419 | |
| 420 | void CServerBrowser::Filter() |
| 421 | { |
| 422 | m_NumSortedPlayers = 0; |
| 423 | |
| 424 | m_vSortedServerlist.clear(); |
| 425 | m_vSortedServerlist.reserve(m_vpServerlist.size()); |
| 426 | |
| 427 | for(auto &Community : m_vCommunities) |
| 428 | { |
| 429 | Community.m_NumPlayers = 0; |
| 430 | } |
| 431 | |
| 432 | // filter the servers |
| 433 | for(int ServerIndex = 0; ServerIndex < (int)m_vpServerlist.size(); ServerIndex++) |
| 434 | { |
| 435 | CServerInfo &Info = m_vpServerlist[ServerIndex]->m_Info; |
| 436 | bool Filtered = false; |
| 437 | |
| 438 | if(g_Config.m_BrFilterEmpty && Info.m_NumFilteredPlayers == 0) |
| 439 | Filtered = true; |
| 440 | else if(g_Config.m_BrFilterFull && Players(Info) == Max(Info)) |
| 441 | Filtered = true; |
| 442 | else if(g_Config.m_BrFilterPw && Info.m_Flags & SERVER_FLAG_PASSWORD) |
| 443 | Filtered = true; |
| 444 | else if(g_Config.m_BrFilterServerAddress[0] && !str_find_nocase(Info.m_aAddress, g_Config.m_BrFilterServerAddress)) |
| 445 | Filtered = true; |
| 446 | else if(g_Config.m_BrFilterGametypeStrict && g_Config.m_BrFilterGametype[0] && str_comp_nocase(Info.m_aGameType, g_Config.m_BrFilterGametype)) |
| 447 | Filtered = true; |
| 448 | else if(!g_Config.m_BrFilterGametypeStrict && g_Config.m_BrFilterGametype[0] && !str_utf8_find_nocase(Info.m_aGameType, g_Config.m_BrFilterGametype)) |
| 449 | Filtered = true; |
| 450 | else if(g_Config.m_BrFilterUnfinishedMap && Info.m_HasRank == CServerInfo::RANK_RANKED) |
| 451 | Filtered = true; |
| 452 | else if(g_Config.m_BrFilterLogin && Info.m_RequiresLogin) |
| 453 | Filtered = true; |
| 454 | else |
| 455 | { |
| 456 | if(!Communities().empty()) |
| 457 | { |
| 458 | if(m_ServerlistType == IServerBrowser::TYPE_INTERNET || m_ServerlistType == IServerBrowser::TYPE_FAVORITES) |
| 459 | { |
| 460 | Filtered = CommunitiesFilter().Filtered(Info.m_aCommunityId); |
| 461 | } |
| 462 | if(m_ServerlistType == IServerBrowser::TYPE_INTERNET || m_ServerlistType == IServerBrowser::TYPE_FAVORITES || |
| 463 | (m_ServerlistType >= IServerBrowser::TYPE_FAVORITE_COMMUNITY_1 && m_ServerlistType <= IServerBrowser::TYPE_FAVORITE_COMMUNITY_5)) |
| 464 | { |
| 465 | Filtered = Filtered || CountriesFilter().Filtered(Info.m_aCommunityCountry); |
| 466 | Filtered = Filtered || TypesFilter().Filtered(Info.m_aCommunityType); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | if(!Filtered && g_Config.m_BrFilterCountry) |
| 471 | { |
| 472 | Filtered = true; |
| 473 | // match against player country |
| 474 | for(int p = 0; p < minimum(Info.m_NumClients, (int)MAX_CLIENTS); p++) |
| 475 | { |
| 476 | if(Info.m_aClients[p].m_Country == g_Config.m_BrFilterCountryIndex) |
| 477 | { |
nothing calls this directly
no test coverage detected