From 74ef14ab3ff62deaa3fbfa8c6f6a51a1e884aaad Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sun, 5 Nov 2023 13:23:49 +1300 Subject: [PATCH] Refresh server browser on disconnect (closes #1782) Adds a new client setting which determines whether the server browser should be refreshed once the player disconnects from a server. This would remove the need for manually refreshing the server browser, which would probably contain very outdated information by the time the player disconnects. --- src/engine/client/client.cpp | 4 ++++ src/game/client/components/menus_settings.cpp | 8 +++++++- src/game/variables.h | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 39ca1cb73b..10bf4ae290 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -605,6 +605,10 @@ void CClient::DisconnectWithReason(const char *pReason) m_aSnapshots[SNAP_CURRENT] = 0; m_aSnapshots[SNAP_PREV] = 0; m_ReceivedSnapshots = 0; + + // refresh server list + if (Config()->m_ClRefreshServerBrowserOnDisconnect) + m_ServerBrowser.Refresh(IServerBrowser::REFRESHFLAG_LAN|IServerBrowser::REFRESHFLAG_INTERNET); } void CClient::Disconnect() diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 59f6c6fb55..cd2e1acb2b 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -849,7 +849,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) Game.Draw(vec4(0.0f, 0.0f, 0.0f, 0.25f)); // render client menu background - NumOptions = 4; + NumOptions = 5; BackgroundHeight = (float)(NumOptions+1)*ButtonHeight+(float)NumOptions*Spacing; MainView.HSplitTop(10.0f, 0, &MainView); @@ -1010,6 +1010,12 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) if(Config()->m_ClAutoScreenshot) UI()->DoScrollbarOption(&Config()->m_ClAutoScreenshotMax, &Config()->m_ClAutoScreenshotMax, &ClientRight, Localize("Max"), 0, 1000, &CUI::ms_LogarithmicScrollbarScale, true); + Client.HSplitTop(Spacing, 0, &Client); + Client.HSplitTop(ButtonHeight, &ClientLeft, &Client); + ClientLeft.VSplitMid(&ClientLeft, &ClientRight, Spacing); + if(DoButton_CheckBox(&Config()->m_ClRefreshServerBrowserOnDisconnect, Localize("Automatically refresh server browser on disconnect"), Config()->m_ClRefreshServerBrowserOnDisconnect, &ClientLeft)) + Config()->m_ClRefreshServerBrowserOnDisconnect ^= 1; + MainView.HSplitTop(10.0f, 0, &MainView); // render language and theme selection diff --git a/src/game/variables.h b/src/game/variables.h index 78f24f20e3..5e03870ee1 100644 --- a/src/game/variables.h +++ b/src/game/variables.h @@ -102,6 +102,7 @@ MACRO_CONFIG_INT(ClCameraSpeed, cl_camera_speed, 5, 1, 10, CFGFLAG_CLIENT|CFGFLA MACRO_CONFIG_INT(ClShowStartMenuImages, cl_show_start_menu_images, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show start menu images") MACRO_CONFIG_INT(ClSkipStartMenu, cl_skip_start_menu, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Skip the start menu") +MACRO_CONFIG_INT(ClRefreshServerBrowserOnDisconnect, cl_refresh_server_browser_on_disconnect, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Automatically refresh server browser on disconnect") MACRO_CONFIG_INT(ClHideSelfScore, cl_hide_self_score, 0, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Hide player's score in the scoreboard") MACRO_CONFIG_INT(ClStatboardInfos, cl_statboard_infos, 1259, 1, 2047, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Mask of info to display on the global statboard")