From 28931a8194b6c4b5569cda383c22bcbd664c42b4 Mon Sep 17 00:00:00 2001 From: z411 Date: Sun, 28 May 2023 02:36:34 -0400 Subject: [PATCH] Retract from queue by spectating --- qcsrc/common/notifications/all.inc | 1 + qcsrc/server/clientkill.qc | 6 +++++- qcsrc/server/command/cmd.qc | 2 +- qcsrc/server/teamplay.qc | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index 52be4acff..cbcf5aa05 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -786,6 +786,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input != MSG_CENTER_NOTIF(TIMEOUT_ENDING, N_ENABLE, 0, 1, "", CPID_TIMEIN, "1 f1", _("^F4Timeout ends in ^COUNT"), "") MSG_CENTER_NOTIF(JOIN_PREVENT_MINIGAME, N_ENABLE, 0, 0, "", CPID_Null, "0 0", _("^K1Cannot join given minigame session!"), "" ) + MSG_CENTER_NOTIF(JOIN_PREVENT_QUEUE, N_ENABLE, 0, 0, "", CPID_Null, "0 0", _("^BGYou are now queued to join the game."), "") MSG_CENTER_NOTIF(VEHICLE_ENTER, N_ENABLE, 0, 0, "pass_key", CPID_VEHICLES, "0 0", _("^BGPress ^F2%s^BG to enter/exit the vehicle"), "") MSG_CENTER_NOTIF(VEHICLE_ENTER_GUNNER, N_ENABLE, 0, 0, "pass_key", CPID_VEHICLES, "0 0", _("^BGPress ^F2%s^BG to enter the vehicle gunner"), "") diff --git a/qcsrc/server/clientkill.qc b/qcsrc/server/clientkill.qc index 296a95bfe..660d02e36 100644 --- a/qcsrc/server/clientkill.qc +++ b/qcsrc/server/clientkill.qc @@ -25,7 +25,11 @@ void ClientKill_Now_TeamChange(entity this) { if (blockSpectators) Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime); - PutObserverInServer(this, false, true); + + if (CS(this).wants_join) + SetPlayerTeam(this, -1, TEAM_CHANGE_SPECTATOR); + else + PutObserverInServer(this, false, true); } else { diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 947edd891..67016dd89 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -593,7 +593,7 @@ void ClientCommand_spectate(entity caller, int request) if (mutator_returnvalue == MUT_SPECCMD_RETURN) return; - if ((IS_PLAYER(caller) || mutator_returnvalue == MUT_SPECCMD_FORCE)) + if ((IS_PLAYER(caller) || mutator_returnvalue == MUT_SPECCMD_FORCE || CS(caller).wants_join)) if (autocvar_sv_spectate == 1) ClientKill_TeamChange(caller, -2); // observe } diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 18e2060e5..89d9ad1cf 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -276,6 +276,7 @@ bool SetPlayerTeam(entity player, int team_index, int type) if (IsQueueNeeded(player) && !SpectatorWantsJoin(player)) { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_WANTS_TEAM), player.netname); + Send_Notification(NOTIF_ALL, NULL, MSG_CENTER, CENTER_JOIN_PREVENT_QUEUE); CS(player).wants_join = true; // TODO : Refactor } else @@ -291,6 +292,11 @@ bool SetPlayerTeam(entity player, int team_index, int type) Kill_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CPID_IDLING); CS(player).idlekick_lasttimeleft = 0; } + else if (CS(player).wants_join) + { + CS(player).wants_join = false; + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname); + } else if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR) { Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname); -- 2.39.2