]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
On manual disconnection make sure g_campaign is reset and menu items reflect cvar...
authorterencehill <piuntn@gmail.com>
Mon, 3 May 2021 23:29:21 +0000 (01:29 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 4 May 2021 08:45:51 +0000 (10:45 +0200)
qcsrc/menu/menu.qc
qcsrc/menu/menu.qh

index 710dca1e6685be3d57671237bd9a1647148cfa55..8a00d713f1287186de24c77ad1710462a3310327 100644 (file)
@@ -673,6 +673,7 @@ void m_tooltip(vector pos)
 }
 
 float autocvar_menu_force_on_disconnection;
+bool autocvar_g_campaign;
 void m_draw(float width, float height)
 {
        if (autocvar_menu_force_on_disconnection > 0)
@@ -680,6 +681,14 @@ void m_draw(float width, float height)
                static float connected_time;
                if (clientstate() == CS_DISCONNECTED)
                {
+                       if (autocvar_g_campaign)
+                       {
+                               // in the case player uses the disconnect command (in the console or with a key)
+                               // reset g_campaign and update menu items to reflect cvar values that may have been restored after quiting the campaign
+                               // see also QUITGAME_CMD
+                               cvar_set("g_campaign", "0");
+                               m_sync();
+                       }
                        if (connected_time && time - connected_time > autocvar_menu_force_on_disconnection)
                        {
                                m_toggle(true);
index d4c8ea6baae8331c296e1350cb980fe3cd1f51f6..239c66152e9dcca17a6af58583266968c0c5d267 100644 (file)
@@ -18,7 +18,8 @@ int gamestatus;
 // resets g_campaign and updates menu items to reflect cvar values that may have been restored after leaving the campaign
 // the delay is for allowing listening to the button sound (if enabled), since the disconnect command stops all sounds
 // menu_sync is also useful when quitting Instant Action mode
-const string QUITGAME_CMD = "defer 0.4 disconnect; defer 0.4 wait; defer 0.4 \"g_campaign 0\"; defer 0.4 menu_sync";
+// see also m_draw
+const string QUITGAME_CMD = "defer 0.4 disconnect; defer 0.4 wait; defer 0.4 \"g_campaign 0\"; defer 0.4 menu_sync\n";
 
 const int S_SHIFT = 1;
 const int S_CTRL = 2;