From: bones_was_here Date: Sat, 10 May 2025 10:58:35 +0000 (+1000) Subject: join queue: leave queue with F3 (spec) when queued to swap teams X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=005a78edcb4e21ddbe8b5e5c6cf9540e5fd97f33;p=xonotic%2Fxonotic-data.pk3dir.git join queue: leave queue with F3 (spec) when queued to swap teams Fixes erroring out the server or killing the player when they're queued to switch teams and try to leave the queue. IIRC the initial implementation put the player on the team they wanted to join even when they were only queued, which would explain the SetPlayerTeam() call (which causes the server error) in ClientKill_Now_TeamChange(). --- diff --git a/qcsrc/server/clientkill.qc b/qcsrc/server/clientkill.qc index 3d04c13c08..55cb3d048f 100644 --- a/qcsrc/server/clientkill.qc +++ b/qcsrc/server/clientkill.qc @@ -36,23 +36,10 @@ void ClientKill_Now_TeamChange(entity this) // shouldn't get here because of condition in ClientCommand_spectate() Send_Notification(NOTIF_ONE_ONLY, this, MSG_INFO, INFO_SPECTATE_WARNING, autocvar_g_maxplayers_spectator_blocktime); - if (this.wants_join) - { - Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_PREVENT_JOIN); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_QUEUE, this.netname); - SetPlayerTeam(this, -1, TEAM_CHANGE_SPECTATOR); - // Can't do this in PutObserverInServer() or SetPlayerTeam() cos it causes - // mouse2 (change spectate mode) to kick the player off the join queue. - this.wants_join = 0; - this.team_selected = 0; - } - else - { - PutObserverInServer(this, false, true); - if (!TeamBalance_QueuedPlayersTagIn(this)) - if (autocvar_g_balance_teams_remove) - TeamBalance_RemoveExcessPlayers(this); - } + PutObserverInServer(this, false, true); + if (!TeamBalance_QueuedPlayersTagIn(this)) + if (autocvar_g_balance_teams_remove) + TeamBalance_RemoveExcessPlayers(this); } else { diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 7d8d5b63c8..cd99b02e4c 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -781,11 +781,21 @@ void ClientCommand_spectate(entity caller, int request) if (mutator_returnvalue == MUT_SPECCMD_RETURN) return; - if ((IS_PLAYER(caller) || mutator_returnvalue == MUT_SPECCMD_FORCE || caller.wants_join)) - if (autocvar_sv_spectate) - ClientKill_TeamChange(caller, -2); // observe - else - Send_Notification(NOTIF_ONE_ONLY, caller, MSG_MULTI, SPECTATE_NOTALLOWED); + // if queued the first spec command shall only leave the queue (player might be on a team, queued to switch) + if (caller.wants_join) + { + Kill_Notification(NOTIF_ONE_ONLY, caller, MSG_CENTER, CPID_PREVENT_JOIN); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_QUEUE, caller.netname); + caller.wants_join = 0; + caller.team_selected = 0; + } + else if ((IS_PLAYER(caller) || mutator_returnvalue == MUT_SPECCMD_FORCE)) + { + if (autocvar_sv_spectate) + ClientKill_TeamChange(caller, -2); // observe + else + Send_Notification(NOTIF_ONE_ONLY, caller, MSG_MULTI, SPECTATE_NOTALLOWED); + } } return; // never fall through to usage }