]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Forfeit dialog: implement backward compatibility: no forfeit confirmation for old...
authorterencehill <piuntn@gmail.com>
Fri, 20 Sep 2024 18:19:25 +0000 (20:19 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 20 Sep 2024 18:19:25 +0000 (20:19 +0200)
Also fix wrong command name sent by the server

qcsrc/common/replicate.qh
qcsrc/menu/xonotic/dialog_forfeit.qc
qcsrc/server/command/cmd.qc

index 6c66771f8aab4a812e50b9030385a3d688c19651..afc1c7b97eeef3f705027ada36135527cf702afa 100644 (file)
@@ -3,6 +3,7 @@
 // TODO: Remove cvar_cl_handicap vector after 0.9 release
 
 #ifdef GAMEQC
+REPLICATE_INIT(bool, cvar__menu_forfeit_dialog_available);
 REPLICATE_INIT(bool, cvar_cl_autoswitch);
 REPLICATE_INIT(int, cvar_cl_autoscreenshot);
 REPLICATE_INIT(bool, cvar_cl_clippedspectating);
@@ -12,6 +13,7 @@ REPLICATE_INIT(float, cvar_cl_handicap_damage_given);
 REPLICATE_INIT(float, cvar_cl_handicap_damage_taken);
 REPLICATE_INIT(bool, cvar_cl_noantilag);
 REPLICATE_INIT(string, cvar_g_xonoticversion);
+REPLICATE(cvar__menu_forfeit_dialog_available, bool, "_menu_forfeit_dialog_available");
 REPLICATE(cvar_cl_autoswitch, bool, "cl_autoswitch");
 REPLICATE(cvar_cl_autoscreenshot, int, "cl_autoscreenshot");
 REPLICATE(cvar_cl_clippedspectating, bool, "cl_clippedspectating");
index c6e2bca46ae78eef66011f15adb04caaae5cd1e8..48de567631d328601e241f68a7bd259420cc2739 100644 (file)
@@ -4,8 +4,16 @@
 #include "commandbutton.qh"
 #include "textlabel.qh"
 
+void XonoticForfeitDialog_destroy(entity me)
+{
+       cvar_set("_menu_forfeit_dialog_available", "0");
+}
+
 void XonoticForfeitDialog_fill(entity me)
 {
+       registercvar("_menu_forfeit_dialog_available", "0", 0);
+       cvar_set("_menu_forfeit_dialog_available", "1");
+
        entity e;
        me.TR(me);
                me.TD(me, 1, 2, makeXonoticTextLabel(0.5, _("Are you sure you want to observe and quit current match?")));
index e527029b53aa35b4bf1efa015952ac073049a6d3..cbc1df1eecc10c768373723b2d9ba7fc435ba843 100644 (file)
@@ -714,7 +714,7 @@ void ClientCommand_spectate(entity caller, int request)
                                if (argv(2) == "FORFEIT" || warmup_stage)
                                        caller_wants_to_forfeit = true; // player replied that they want to forfeit
 
-                               if (IS_PLAYER(caller) && !caller_wants_to_forfeit)
+                               if (IS_PLAYER(caller) && !caller_wants_to_forfeit && caller.cvar__menu_forfeit_dialog_available)
                                {
                                        // ask player if they want to forfeit
                                        stuffcmd(caller, "menu_showforfeitdialog\n");
@@ -737,11 +737,11 @@ void ClientCommand_spectate(entity caller, int request)
 
                                if (mutator_returnvalue == MUT_SPECCMD_RETURN_FORFEIT)
                                {
-                                       if (caller_wants_to_forfeit)
+                                       if (caller_wants_to_forfeit || !caller.cvar__menu_forfeit_dialog_available)
                                                mutator_returnvalue = MUT_SPECCMD_FORCE;
                                        else
                                        {
-                                               stuffcmd(caller, "menu_showobservedialog\n");
+                                               stuffcmd(caller, "menu_showforfeitdialog\n");
                                                return;
                                        }
                                }