Fix countries/types filters excluding all servers

Instead of cleaning the countries/types filters based on all available communities' countries/types, only consider the countries/types of currently selected communities. Ensure countries/types are always cleaned when updating the server browser filter in the UI. This fixes that countries/types which are not available for the selected communities were still affecting the server filtering, causing no servers to be shown in some cases.

Closes #7847.
This commit is contained in:
Robert Müller 2024-01-22 22:23:15 +01:00
parent ddd3d25066
commit 797db31aa1
2 changed files with 6 additions and 5 deletions

View file

@ -1569,8 +1569,8 @@ void CServerBrowser::CommunitiesFilterClean()
void CServerBrowser::CountriesFilterClean()
{
std::vector<const char *> vpCountryNames;
for(const auto &Community : Communities())
for(const auto &Country : Community.Countries())
for(const CCommunity *pCommunity : SelectedCommunities())
for(const auto &Country : pCommunity->Countries())
vpCountryNames.push_back(Country.Name());
m_CountriesFilter.Clean(vpCountryNames);
}
@ -1578,8 +1578,8 @@ void CServerBrowser::CountriesFilterClean()
void CServerBrowser::TypesFilterClean()
{
std::vector<const char *> vpTypeNames;
for(const auto &Community : Communities())
for(const auto &Type : Community.Types())
for(const CCommunity *pCommunity : SelectedCommunities())
for(const auto &Type : pCommunity->Types())
vpTypeNames.push_back(Type.Name());
m_TypesFilter.Clean(vpTypeNames);
}

View file

@ -1743,7 +1743,6 @@ void CMenus::ConchainCommunitiesUpdate(IConsole::IResult *pResult, void *pUserDa
CMenus *pThis = static_cast<CMenus *>(pUserData);
if(pResult->NumArguments() >= 1 && (g_Config.m_UiPage == PAGE_INTERNET || g_Config.m_UiPage == PAGE_FAVORITES))
{
pThis->ServerBrowser()->CleanFilters();
pThis->UpdateCommunityCache(true);
pThis->Client()->ServerBrowserUpdate();
}
@ -1755,6 +1754,8 @@ void CMenus::UpdateCommunityCache(bool Force)
if(!Force && m_CommunityCache.m_UpdateTime != 0 && m_CommunityCache.m_UpdateTime == ServerBrowser()->DDNetInfoUpdateTime() && m_CommunityCache.m_PageWithCommunities == PageWithCommunities)
return;
ServerBrowser()->CleanFilters();
m_CommunityCache.m_UpdateTime = ServerBrowser()->DDNetInfoUpdateTime();
m_CommunityCache.m_PageWithCommunities = PageWithCommunities;