From: terencehill Date: Sun, 13 Mar 2022 13:41:58 +0000 (+0100) Subject: Add isServerSingleplayer X-Git-Tag: xonotic-v0.8.5~129^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=23af7cff89c0c285ca417a041230206362ee0287;p=xonotic%2Fxonotic-data.pk3dir.git Add isServerSingleplayer --- diff --git a/qcsrc/menu/xonotic/leavematchbutton.qc b/qcsrc/menu/xonotic/leavematchbutton.qc index efaafc120..e58cbc54a 100644 --- a/qcsrc/menu/xonotic/leavematchbutton.qc +++ b/qcsrc/menu/xonotic/leavematchbutton.qc @@ -12,7 +12,7 @@ string leaveMatchButton_getText(entity me) return _("Leave current match"); else if(cvar("g_campaign")) return _("Leave campaign"); - else if (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1") + else if (isServerSingleplayer()) return _("Leave singleplayer"); else return _("Leave multiplayer"); @@ -24,7 +24,7 @@ string leaveMatchButton_getTooltip(entity me) return "-"; else if(cvar("g_campaign")) return _("Leave current campaign level"); - else if (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1") + else if (isServerSingleplayer()) return _("Leave current singleplayer match"); else return _("Leave current multiplayer match / Disconnect from the server"); diff --git a/qcsrc/menu/xonotic/util.qc b/qcsrc/menu/xonotic/util.qc index f5feb7c98..63eb27abf 100644 --- a/qcsrc/menu/xonotic/util.qc +++ b/qcsrc/menu/xonotic/util.qc @@ -829,8 +829,14 @@ void dialog_hudpanel_main_settings(entity me, string panelname) e.configureXonoticTextSliderValues(e); } +bool isServerSingleplayer() +{ + return (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1"); +} + void makeServerSingleplayer() { + // it doesn't allow clients to connect from different machines localcmd("defer 0.1 \"sv_cmd settemp net_address 127.0.0.1\"\n"); localcmd("defer 0.1 \"sv_cmd settemp net_address_ipv6 ::1\"\n"); } diff --git a/qcsrc/menu/xonotic/util.qh b/qcsrc/menu/xonotic/util.qh index 72d4e4ff3..bb5de1b51 100644 --- a/qcsrc/menu/xonotic/util.qh +++ b/qcsrc/menu/xonotic/util.qh @@ -39,7 +39,9 @@ int GameType_GetTotalCount(); void dialog_hudpanel_main_checkbox(entity me, string panelname); void dialog_hudpanel_main_settings(entity me, string panelname); +bool isServerSingleplayer(); void makeServerSingleplayer(); + float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha); string _Nex_ExtResponseSystem_BannedServers;