diff --git a/src/engine/client/serverbrowser.cpp b/src/engine/client/serverbrowser.cpp index 53b8dc5d94d..2b649ef5f5d 100644 --- a/src/engine/client/serverbrowser.cpp +++ b/src/engine/client/serverbrowser.cpp @@ -1233,11 +1233,17 @@ void CServerBrowser::LoadDDNetServers() m_CommunityServersByAddr.clear(); if(!m_pDDNetInfo) + { + CleanFilters(); return; + } const json_value &Communities = (*m_pDDNetInfo)["communities"]; if(Communities.type != json_array) + { + CleanFilters(); return; + } for(unsigned CommunityIndex = 0; CommunityIndex < Communities.u.array.length; ++CommunityIndex) { @@ -1524,6 +1530,7 @@ bool CFilterList::Empty() const void CFilterList::Clean(const std::vector &vpAllowedElements) { + size_t NumFiltered = 0; char aNewList[512]; aNewList[0] = '\0'; @@ -1534,10 +1541,15 @@ void CFilterList::Clean(const std::vector &vpAllowedElements) if(aNewList[0] != '\0') str_append(aNewList, ","); str_append(aNewList, pElement); + ++NumFiltered; } } - str_copy(m_pFilter, aNewList, m_FilterSize); + // Prevent filter that would exclude all allowed elements + if(NumFiltered == vpAllowedElements.size()) + m_pFilter[0] = '\0'; + else + str_copy(m_pFilter, aNewList, m_FilterSize); } void CServerBrowser::CleanFilters() diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index 5f132788ff1..171ef66d509 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -688,8 +688,6 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) // community filter if((g_Config.m_UiPage == PAGE_INTERNET || g_Config.m_UiPage == PAGE_FAVORITES) && !ServerBrowser()->Communities().empty()) { - ServerBrowser()->CleanFilters(); - CUIRect Row; View.HSplitTop(6.0f, nullptr, &View); View.HSplitTop(19.0f, &Row, &View); @@ -1742,8 +1740,13 @@ void CMenus::ConchainFavoritesUpdate(IConsole::IResult *pResult, void *pUserData void CMenus::ConchainCommunitiesUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData) { pfnCallback(pResult, pCallbackUserData); + CMenus *pThis = static_cast(pUserData); if(pResult->NumArguments() >= 1 && (g_Config.m_UiPage == PAGE_INTERNET || g_Config.m_UiPage == PAGE_FAVORITES)) - ((CMenus *)pUserData)->UpdateCommunityCache(true); + { + pThis->ServerBrowser()->CleanFilters(); + pThis->UpdateCommunityCache(true); + pThis->Client()->ServerBrowserUpdate(); + } } void CMenus::UpdateCommunityCache(bool Force)