]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
spec command: catch mutator blocking of player argument
authorbones_was_here <bones_was_here@xonotic.au>
Wed, 30 Apr 2025 14:06:05 +0000 (00:06 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 2 May 2025 09:07:34 +0000 (19:07 +1000)
Returns the error instead of failing silently by spectating a different
player.

qcsrc/server/command/cmd.qc

index 1663fe17bde1879d72e2c51babf47480558763fd..5c22952edccb5bf5c2836bf78ee242e06ce36840 100644 (file)
@@ -765,12 +765,11 @@ void ClientCommand_spectate(entity caller, int request)
                                        else
                                        {
                                                entity client = GetFilteredEntity(argv(1));
-                                               float spec_accepted = VerifyClientEntity(client, false, false);
-                                               if(spec_accepted > 0 && IS_PLAYER(client))
+                                               if (IS_PLAYER(client)
+                                               && VerifyClientEntity(client, false, false)
+                                               && Spectate(caller, client)) // mutator hook might say no
                                                {
-                                                       bool caller_is_observer = (IS_OBSERVER(caller));
-                                                       Spectate(caller, client);
-                                                       if (caller_is_observer)
+                                                       if (IS_OBSERVER(caller))
                                                                TRANSMUTE(Spectator, caller);
                                                }
                                                else