]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Refactor spec_forfeit to avoid networking spec_forfeit_ask and _menu_forfeit_dialog_a...
authorterencehill <piuntn@gmail.com>
Tue, 29 Oct 2024 14:06:51 +0000 (15:06 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 29 Oct 2024 14:06:51 +0000 (15:06 +0100)
commands.cfg
qcsrc/common/replicate.qh
qcsrc/server/command/cmd.qc

index b748e8ed227391c9d21302a07851af8e6ad7f29b..8c66f551c5722a57f7ac81b109e8fee60da68cd2 100644 (file)
@@ -217,7 +217,7 @@ alias team_auto "togglemenu 0; cmd selectteam auto; cmd join"
 seta _spec_forfeit_bindupdate 0
 
 seta spec_forfeit_ask 1 "allow asking for forfeit confirmation"
-alias spec_forfeit "spectate \"\" ASK_FORFEIT"
+alias spec_forfeit "spectate \"\" ${spec_forfeit_ask}${_menu_forfeit_dialog_available}"
 
 alias spec "spectate ${* ?}"
 
index 85298a35d69a6bb01b19422ec5f39d7d104771b6..6c66771f8aab4a812e50b9030385a3d688c19651 100644 (file)
@@ -3,8 +3,6 @@
 // TODO: Remove cvar_cl_handicap vector after 0.9 release
 
 #ifdef GAMEQC
-REPLICATE_INIT(bool, cvar_spec_forfeit_ask);
-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);
@@ -14,8 +12,6 @@ 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_spec_forfeit_ask, bool, "spec_forfeit_ask");
-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 7202a9116ddc652fef14311c7d53bfb6fa919bff..4fb7cf5f4fc396a3bf7ce8af2705c11ae8960c00 100644 (file)
@@ -710,10 +710,9 @@ void ClientCommand_spectate(entity caller, int request)
                                        return;
                                }
 
-                               bool forfeit_now =
-                                       (warmup_stage || !caller.cvar_spec_forfeit_ask || argv(2) != "ASK_FORFEIT");
+                               bool forfeit_ask = (!warmup_stage && stof(argv(2)));
 
-                               if (IS_PLAYER(caller) && !forfeit_now && caller.cvar__menu_forfeit_dialog_available)
+                               if (IS_PLAYER(caller) && forfeit_ask)
                                {
                                        // ask player to confirm the forfeit
                                        stuffcmd(caller, "menu_showforfeitdialog\n");
@@ -736,7 +735,7 @@ void ClientCommand_spectate(entity caller, int request)
 
                                if (mutator_returnvalue == MUT_SPECCMD_RETURN_FORFEIT)
                                {
-                                       if (forfeit_now || !caller.cvar__menu_forfeit_dialog_available)
+                                       if (!forfeit_ask)
                                                mutator_returnvalue = MUT_SPECCMD_FORCE;
                                        else
                                        {
@@ -757,10 +756,10 @@ void ClientCommand_spectate(entity caller, int request)
                default:
                case CMD_REQUEST_USAGE:
                {
-                       sprint(caller, "\nUsage:^3 cmd spectate [<client>] [ASK_FORFEIT]\n");
+                       sprint(caller, "\nUsage:^3 cmd spectate [<client>] [<ask_forfeit>]\n");
                        sprint(caller, "  Where <client> can be the player to spectate.\n");
                        sprint(caller, "  If <client> is \"\" or not specified, caller becomes observer.\n");
-                       sprint(caller, "  If <client> is \"\", ASK_FORFEIT means caller will be asked"
+                       sprint(caller, "  If <client> is \"\" and forfeit_ask is not 0 caller will be asked"
                                         " to confirm forfeiting the current game.\n");
                        return;
                }