From 8dff9f37da1b86f7ce2089f6f8f24ea74c421d51 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 20 Sep 2024 20:19:25 +0200 Subject: [PATCH] Forfeit dialog: implement backward compatibility: no forfeit confirmation for old menus Also fix wrong command name sent by the server --- qcsrc/common/replicate.qh | 2 ++ qcsrc/menu/xonotic/dialog_forfeit.qc | 8 ++++++++ qcsrc/server/command/cmd.qc | 6 +++--- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qcsrc/common/replicate.qh b/qcsrc/common/replicate.qh index 6c66771f8..afc1c7b97 100644 --- a/qcsrc/common/replicate.qh +++ b/qcsrc/common/replicate.qh @@ -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"); diff --git a/qcsrc/menu/xonotic/dialog_forfeit.qc b/qcsrc/menu/xonotic/dialog_forfeit.qc index c6e2bca46..48de56763 100644 --- a/qcsrc/menu/xonotic/dialog_forfeit.qc +++ b/qcsrc/menu/xonotic/dialog_forfeit.qc @@ -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?"))); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index e527029b5..cbc1df1ee 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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; } } -- 2.39.2