]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add isServerSingleplayer
authorterencehill <piuntn@gmail.com>
Sun, 13 Mar 2022 13:41:58 +0000 (14:41 +0100)
committerterencehill <piuntn@gmail.com>
Sun, 13 Mar 2022 13:41:58 +0000 (14:41 +0100)
qcsrc/menu/xonotic/leavematchbutton.qc
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

index efaafc120214da7a6f52b3e05342c4b6e9c7dbfd..e58cbc54a2c4b1be3df950a8c53dd60fc453781d 100644 (file)
@@ -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");
index f5feb7c98f314244e3296867261ed3039083ac6b..63eb27abf7b4ffba689280b1f4c83f4faa8357f5 100644 (file)
@@ -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");
 }
index 72d4e4ff36d942534a126cf25699609d9f0bc92d..bb5de1b5141e6769068fd473d3b9b63e8ead67d5 100644 (file)
@@ -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;