Skip to content

Commit

Permalink
refresh server browser on disconnect
Browse files Browse the repository at this point in the history
Add a new client setting that 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.

Closes teeworlds#1782
  • Loading branch information
jtbx committed Jul 27, 2024
1 parent c56fa9e commit c15848a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/engine/client/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 7 additions & 1 deletion src/game/client/components/menus_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,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);
Expand Down Expand Up @@ -988,6 +988,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, CUI::SCROLLBAR_OPTION_INFINITE);

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
Expand Down
1 change: 1 addition & 0 deletions src/game/variables.h
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit c15848a

Please sign in to comment.