]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't allow other clients to connect when starting a singleplayer game; also the...
authorterencehill <piuntn@gmail.com>
Mon, 24 May 2021 14:39:41 +0000 (16:39 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 24 May 2021 15:12:29 +0000 (17:12 +0200)
qcsrc/common/campaign_setup.qc
qcsrc/menu/xonotic/dialog_multiplayer_create.qc
qcsrc/menu/xonotic/dialog_quit.qc
qcsrc/menu/xonotic/dialog_singleplayer.qc
qcsrc/menu/xonotic/util.qc
qcsrc/menu/xonotic/util.qh

index 8be208980a3061d1b595d04ccb40c25235538f37..2b174a68de0a0422cb81bc9d3efc30b8c73acc49 100644 (file)
@@ -18,4 +18,7 @@ void CampaignSetup(int n)
                localcmd("\n");
        localcmd("disconnect\nmaxplayers 16\n");
        MapInfo_LoadMap(campaign_mapname[n], 1);
+       #ifdef MENUQC
+       makeServerSingleplayer();
+       #endif
 }
index 89e015bd798dd24b2993de5ce4a33a0204490125..b2c8de1f780a677ef8f5fbedd1d41827ff001431 100644 (file)
@@ -70,10 +70,7 @@ void XonoticServerCreateTab_draw(entity me)
 {
        entity e = me.quitGameButton;
        e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
-       if(cvar("g_campaign"))
-               e.setText(e, _("Quit campaign"));
-       else
-               e.setText(e, _("Quit current game"));
+       e.setText(e, quitGameButton_getText(e));
        SUPER(XonoticServerCreateTab).draw(me);
 }
 
index b9b18e72ef27e22b900348ae9ec9a086cbe8682c..1bd90038ad48fead20918d686d9c79d03c30663b 100644 (file)
@@ -14,10 +14,7 @@ void XonoticQuitDialog_draw(entity me)
 {
        entity e = me.disconnectButton;
        e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
-       if(cvar("g_campaign"))
-               e.setText(e, _("Quit campaign"));
-       else
-               e.setText(e, _("Quit current game"));
+       e.setText(e, quitGameButton_getText(e));
        SUPER(XonoticQuitDialog).draw(me);
 }
 
index b90218fcf989e7b40b3aa3bc5438bd681497db07..775f4a5b958ae1e0c7504ecd7a1bb6c99ebfb4e8 100644 (file)
@@ -121,6 +121,8 @@ void InstantAction_LoadMap(entity btn, entity dummy)
        localcmd("disconnect\n");
        localcmd("g_campaign 0\n");
 
+       makeServerSingleplayer();
+
        MapInfo_LoadMap(s, 1);
 
        // configure bots
@@ -142,10 +144,7 @@ void XonoticSingleplayerDialog_draw(entity me)
 {
        entity e = me.quitGameButton;
        e.disabled = !(gamestatus & (GAME_ISSERVER | GAME_CONNECTED));
-       if(cvar("g_campaign"))
-               e.setText(e, _("Quit campaign"));
-       else
-               e.setText(e, _("Quit current game"));
+       e.setText(e, quitGameButton_getText(e));
        SUPER(XonoticSingleplayerDialog).draw(me);
 }
 
index e77049d200153e9c2f15fb0ca097edd1c1649fe3..3283476b13b0eda9f1abe3c37b50a07b7f1a2c1f 100644 (file)
@@ -817,6 +817,24 @@ void dialog_hudpanel_main_settings(entity me, string panelname)
                                e.configureXonoticTextSliderValues(e);
 }
 
+void makeServerSingleplayer()
+{
+       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");
+}
+
+string quitGameButton_getText(entity btn)
+{
+       if (btn.disabled)
+               return _("Quit current game");
+       else if(cvar("g_campaign"))
+               return _("Quit campaign");
+       else if (cvar_string("net_address") == "127.0.0.1" && cvar_string("net_address_ipv6") == "::1")
+               return _("Quit singleplayer");
+       else
+               return _("Quit multiplayer");
+}
+
 float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha)
 {
        if(startAlpha < targetAlpha)
index f5bd636d81f98c1b481b0919776ed2051d5fddaf..a4e37c7c9593689fcad22aa3488b60bab299203a 100644 (file)
@@ -39,6 +39,9 @@ int GameType_GetTotalCount();
 void dialog_hudpanel_main_checkbox(entity me, string panelname);
 void dialog_hudpanel_main_settings(entity me, string panelname);
 
+void makeServerSingleplayer();
+string quitGameButton_getText(entity btn);
+
 float getFadedAlpha(float currentAlpha, float startAlpha, float targetAlpha);
 
 string _Nex_ExtResponseSystem_BannedServers;