From: terencehill Date: Tue, 29 Oct 2024 14:06:51 +0000 (+0100) Subject: Refactor spec_forfeit to avoid networking spec_forfeit_ask and _menu_forfeit_dialog_a... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=746d8c361468749b1174ff77109cad954e4c37ca;p=xonotic%2Fxonotic-data.pk3dir.git Refactor spec_forfeit to avoid networking spec_forfeit_ask and _menu_forfeit_dialog_available cvars --- diff --git a/commands.cfg b/commands.cfg index b748e8ed2..8c66f551c 100644 --- a/commands.cfg +++ b/commands.cfg @@ -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 ${* ?}" diff --git a/qcsrc/common/replicate.qh b/qcsrc/common/replicate.qh index 85298a35d..6c66771f8 100644 --- a/qcsrc/common/replicate.qh +++ b/qcsrc/common/replicate.qh @@ -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"); diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 7202a9116..4fb7cf5f4 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -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 [] [ASK_FORFEIT]\n"); + sprint(caller, "\nUsage:^3 cmd spectate [] []\n"); sprint(caller, " Where can be the player to spectate.\n"); sprint(caller, " If is \"\" or not specified, caller becomes observer.\n"); - sprint(caller, " If is \"\", ASK_FORFEIT means caller will be asked" + sprint(caller, " If is \"\" and forfeit_ask is not 0 caller will be asked" " to confirm forfeiting the current game.\n"); return; }