From 82f2f94d64e124a585b78d85905397e539a717ab Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 6 Nov 2020 14:41:49 +0000 Subject: [PATCH] Add a checkbox to filter high latency servers (enabled by default with a ping limit of 300) --- qcsrc/menu/xonotic/dialog_multiplayer_join.qc | 9 +++++++-- qcsrc/menu/xonotic/serverlist.qc | 13 +++++++++++++ qcsrc/menu/xonotic/serverlist.qh | 3 +++ xonotic-client.cfg | 2 ++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/qcsrc/menu/xonotic/dialog_multiplayer_join.qc b/qcsrc/menu/xonotic/dialog_multiplayer_join.qc index c79b124d6..d023221bd 100644 --- a/qcsrc/menu/xonotic/dialog_multiplayer_join.qc +++ b/qcsrc/menu/xonotic/dialog_multiplayer_join.qc @@ -36,7 +36,7 @@ void XonoticServerListTab_fill(entity me) slist.controlledTextbox = e; me.gotoRC(me, 0.5, 2.6); - me.TD(me, 1, 0.9, e = makeXonoticCheckBox(0, "menu_slist_categories", ZCTX(_("SRVS^Categories")))); + me.TD(me, 1, 0.75, e = makeXonoticCheckBox(0, "menu_slist_categories", ZCTX(_("SRVS^Categories")))); e.onClickEntity = slist; e.onClick = ServerList_Categories_Click; me.TD(me, 1, 0.6, e = makeXonoticCheckBox_T(0, "menu_slist_showempty", ZCTX(_("SRVS^Empty")), @@ -44,11 +44,16 @@ void XonoticServerListTab_fill(entity me) slist.filterShowEmpty = e.checked; e.onClickEntity = slist; e.onClick = ServerList_ShowEmpty_Click; - me.TD(me, 1, 0.6, e = makeXonoticCheckBox_T(0, "menu_slist_showfull", ZCTX(_("SRVS^Full")), + me.TD(me, 1, 0.5, e = makeXonoticCheckBox_T(0, "menu_slist_showfull", ZCTX(_("SRVS^Full")), _("Show full servers that have no slots available"))); slist.filterShowFull = e.checked; e.onClickEntity = slist; e.onClick = ServerList_ShowFull_Click; + me.TD(me, 1, 0.6, e = makeXonoticCheckBox_T(0, "menu_slist_showlaggy", ZCTX(_("SRVS^Laggy")), + _("Show high latency servers"))); + slist.filterShowLaggy = e.checked; + e.onClickEntity = slist; + e.onClick = ServerList_ShowLaggy_Click; me.TD(me, 1, 0.6, e = makeXonoticCheckBox_T(0, "net_slist_pause", _("Pause"), _("Pause updating the server list to prevent servers from \"jumping around\""))); me.TD(me, 1, 1, e = makeXonoticButton_T(_("Refresh"), '0 0 0', _("Reload the server list"))); diff --git a/qcsrc/menu/xonotic/serverlist.qc b/qcsrc/menu/xonotic/serverlist.qc index 578e1eca6..b0f561d91 100644 --- a/qcsrc/menu/xonotic/serverlist.qc +++ b/qcsrc/menu/xonotic/serverlist.qc @@ -341,6 +341,10 @@ void XonoticServerList_refreshServerList(entity me, int mode) if(!me.filterShowEmpty) sethostcachemasknumber(++m, SLIST_FIELD_NUMHUMANS, 1, SLIST_TEST_GREATEREQUAL); + // show laggy button + if(!me.filterShowLaggy && autocvar_menu_slist_maxping > 0) + sethostcachemasknumber(++m, SLIST_FIELD_PING, autocvar_menu_slist_maxping, SLIST_TEST_LESSEQUAL); + // gametype filtering if(typestr != "") sethostcachemaskstring(++m, SLIST_FIELD_QCSTATUS, strcat(typestr, ":"), SLIST_TEST_STARTSWITH); @@ -679,6 +683,15 @@ void ServerList_ShowFull_Click(entity box, entity me) me.ipAddressBox.cursorPos = 0; me.ipAddressBoxFocused = -1; } +void ServerList_ShowLaggy_Click(entity box, entity me) +{ + box.setChecked(box, me.filterShowLaggy = !me.filterShowLaggy); + me.refreshServerList(me, REFRESHSERVERLIST_REFILTER); + + me.ipAddressBox.setText(me.ipAddressBox, ""); + me.ipAddressBox.cursorPos = 0; + me.ipAddressBoxFocused = -1; +} void XonoticServerList_setSortOrder(entity me, int fld, int direction) { if(me.currentSortField == fld) diff --git a/qcsrc/menu/xonotic/serverlist.qh b/qcsrc/menu/xonotic/serverlist.qh index 8ad1856b0..77236e6d0 100644 --- a/qcsrc/menu/xonotic/serverlist.qh +++ b/qcsrc/menu/xonotic/serverlist.qh @@ -37,6 +37,7 @@ CLASS(XonoticServerList, XonoticListBox) METHOD(XonoticServerList, setSortOrder, void(entity, float, float)); ATTRIB(XonoticServerList, filterShowEmpty, float, 1); ATTRIB(XonoticServerList, filterShowFull, float, 1); + ATTRIB(XonoticServerList, filterShowLaggy, float, 0); ATTRIB(XonoticServerList, filterString, string); ATTRIB(XonoticServerList, controlledTextbox, entity); ATTRIB(XonoticServerList, ipAddressBox, entity); @@ -76,6 +77,7 @@ void ServerList_Filter_Change(entity box, entity me); void ServerList_Categories_Click(entity box, entity me); void ServerList_ShowEmpty_Click(entity box, entity me); void ServerList_ShowFull_Click(entity box, entity me); +void ServerList_ShowLaggy_Click(entity box, entity me); void ServerList_Connect_Click(entity btn, entity me); void ServerList_Update_favoriteButton(entity btn, entity me); void ServerList_Favorite_Click(entity btn, entity me); @@ -108,6 +110,7 @@ float autocvar_menu_slist_categories; float autocvar_menu_slist_categories_onlyifmultiple; float autocvar_menu_slist_purethreshold; float autocvar_menu_slist_modimpurity; +float autocvar_menu_slist_maxping = 300; float autocvar_menu_slist_recommendations; float autocvar_menu_slist_recommendations_maxping; float autocvar_menu_slist_recommendations_minfreeslots; diff --git a/xonotic-client.cfg b/xonotic-client.cfg index ac5212408..bf1735e02 100644 --- a/xonotic-client.cfg +++ b/xonotic-client.cfg @@ -532,12 +532,14 @@ seta accuracy_color2 "0 1 0" // for menu server list (eventually make them have engine support?) seta menu_slist_showfull 1 "show servers even if they are full and have no slots to join" seta menu_slist_showempty 1 "show servers even if they are no empty and have no opponents to play against" +seta menu_slist_showlaggy 0 "show servers even if they are very high latency (see menu_slist_maxping)" seta menu_slist_modfilter "" // set to either: !modname or modname. modname of = means "same as we are running now". // other serverlist cvars seta menu_slist_categories 1 seta menu_slist_categories_onlyifmultiple 1 seta menu_slist_purethreshold 0 +seta menu_slist_maxping 300 seta menu_slist_modimpurity 0 seta menu_slist_recommendations 3 seta menu_slist_recommendations_maxping 150 -- 2.39.2