diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index 73d1e2f25..dc0a664c0 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -27,6 +27,9 @@ #include #include +static constexpr const char *COMMUNITY_COUNTRY_NONE = "none"; +static constexpr const char *COMMUNITY_TYPE_NONE = "None"; + class CSortWrap { typedef bool (CServerBrowser::*SortFunc)(int, int) const; @@ -1497,7 +1500,12 @@ void CServerBrowser::LoadDDNetServers() } // Add default none community - m_vCommunities.emplace_back(COMMUNITY_NONE, "None", SHA256_ZEROED, ""); + { + CCommunity NoneCommunity(COMMUNITY_NONE, "None", SHA256_ZEROED, ""); + NoneCommunity.m_vCountries.emplace_back(COMMUNITY_COUNTRY_NONE, -1); + NoneCommunity.m_vTypes.emplace_back(COMMUNITY_TYPE_NONE); + m_vCommunities.push_back(std::move(NoneCommunity)); + } // Remove unknown elements from exclude lists CleanFilters(); @@ -1543,8 +1551,8 @@ void CServerBrowser::UpdateServerCommunity(CServerInfo *pInfo) const } } str_copy(pInfo->m_aCommunityId, COMMUNITY_NONE); - str_copy(pInfo->m_aCommunityCountry, ""); - str_copy(pInfo->m_aCommunityType, ""); + str_copy(pInfo->m_aCommunityCountry, COMMUNITY_COUNTRY_NONE); + str_copy(pInfo->m_aCommunityType, COMMUNITY_TYPE_NONE); } void CServerBrowser::UpdateServerRank(CServerInfo *pInfo) const @@ -1876,11 +1884,6 @@ void CExcludedCommunityCountryFilterList::Clear() bool CExcludedCommunityCountryFilterList::Filtered(const char *pCountryName) const { - // If the needle is not defined, we exclude it if there is any other - // exclusion, i.e. we only show those elements when the filter is empty. - if(pCountryName[0] == '\0') - return !Empty(); - const auto Communities = m_CurrentCommunitiesGetter(); return std::none_of(Communities.begin(), Communities.end(), [&](const CCommunity *pCommunity) { if(!pCommunity->HasCountry(pCountryName)) @@ -2020,11 +2023,6 @@ void CExcludedCommunityTypeFilterList::Clear() bool CExcludedCommunityTypeFilterList::Filtered(const char *pTypeName) const { - // If the needle is not defined, we exclude it if there is any other - // exclusion, i.e. we only show those elements when the filter is empty. - if(pTypeName[0] == '\0') - return !Empty(); - const auto Communities = m_CurrentCommunitiesGetter(); return std::none_of(Communities.begin(), Communities.end(), [&](const CCommunity *pCommunity) { if(!pCommunity->HasType(pTypeName)) diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 5d826e289..b501af976 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -724,7 +724,9 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) } } - if(!m_CommunityCache.m_vpSelectableCountries.empty() || !m_CommunityCache.m_vpSelectableTypes.empty()) + // countries and types filters (not shown if there are no countries and types, or if only the none community is selected) + if((!m_CommunityCache.m_vpSelectableCountries.empty() || !m_CommunityCache.m_vpSelectableTypes.empty()) && + (m_CommunityCache.m_vpSelectedCommunities.size() != 1 || str_comp(m_CommunityCache.m_vpSelectedCommunities[0]->Id(), IServerBrowser::COMMUNITY_NONE) != 0)) { const ColorRGBA ColorActive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.3f); const ColorRGBA ColorInactive = ColorRGBA(0.0f, 0.0f, 0.0f, 0.15f); @@ -858,7 +860,10 @@ void CMenus::RenderServerbrowserDDNetFilter(CUIRect View, else if(Click == 2) { // Right click: when all are active, only deactivate one - Filter.Add(GetItemName(ItemIndex)); + if(MaxItems >= 2) + { + Filter.Add(GetItemName(ItemIndex)); + } } } else