]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
join queue: leave queue with F3 (spec) when queued to swap teams
authorbones_was_here <bones_was_here@xonotic.au>
Sat, 10 May 2025 10:58:35 +0000 (20:58 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Tue, 13 May 2025 08:26:37 +0000 (18:26 +1000)
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().

qcsrc/server/clientkill.qc
qcsrc/server/command/cmd.qc

index 3d04c13c0854054971c07a4ca883897a163dcf91..55cb3d048fb46f0689b26d6ea9f6d08695d603c7 100644 (file)
@@ -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
        {
index 7d8d5b63c86a6892dd5f7ce77956bc9377014085..cd99b02e4cc7d2f63a3b77886b7b0e2b38e12bc4 100644 (file)
@@ -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
                }