]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
spec: minor internal API refactor 1498/head
authorbones_was_here <bones_was_here@xonotic.au>
Fri, 9 May 2025 09:33:15 +0000 (19:33 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 9 May 2025 09:33:15 +0000 (19:33 +1000)
Moves the TRANSMUTE into the Spectate* funcs such that if they succeed
IS_OBSERVER is false and IS_SPEC is true.

qcsrc/common/mutators/mutator/superspec/sv_superspec.qc
qcsrc/server/client.qc
qcsrc/server/command/cmd.qc

index fe57eaa44c08662366441d313d2be82cd799f75f..184b4e74967d680d1b007ea61dd62abbb9cd41b1 100644 (file)
@@ -27,9 +27,7 @@ const int SSF_ITEMMSG = BIT(2);
 
 bool superspec_Spectate(entity this, entity targ)
 {
-       if(Spectate(this, targ) == 1)
-           TRANSMUTE(Spectator, this);
-
+       Spectate(this, targ);
        return true;
 }
 
index 8e2408736f43228b67fe385415a9f28b4918b3b7..de16a38e2346d42671d90d4af65a64a475c8258a 100644 (file)
@@ -1858,6 +1858,8 @@ bool SpectateUpdate(entity this)
        }
 
        SpectateCopy(this, this.enemy);
+       if (IS_OBSERVER(this))
+               TRANSMUTE(Spectator, this);
 
        return true;
 }
@@ -2496,7 +2498,7 @@ void ObserverOrSpectatorThink(entity this)
                        if (autocvar_sv_spectate == 2 && !warmup_stage && !this.vote_master)
                                Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_SPECTATE_SPEC_NOTALLOWED);
                        else if(SpectateNext(this))
-                               TRANSMUTE(Spectator, this);
+                               { }
                        else if (is_spec)
                        {
                                TRANSMUTE(Observer, this);
@@ -2513,9 +2515,7 @@ void ObserverOrSpectatorThink(entity this)
                        if(CS(this).impulse == 12 || CS(this).impulse == 16  || CS(this).impulse == 19 || (CS(this).impulse >= 220 && CS(this).impulse <= 229))
                        {
                                this.flags &= ~FL_JUMPRELEASED;
-                               if(SpectatePrev(this))
-                                       TRANSMUTE(Spectator, this);
-                               else
+                               if (!SpectatePrev(this))
                                {
                                        TRANSMUTE(Observer, this);
                                        PutClientInServer(this);
index d2f8c4055733162689b7efaef2f34f6827f2b716..7d8d5b63c86a6892dd5f7ce77956bc9377014085 100644 (file)
@@ -770,10 +770,7 @@ void ClientCommand_spectate(entity caller, int request)
                                                if (IS_PLAYER(client)
                                                && VerifyClientEntity(client, false, false)
                                                && Spectate(caller, client)) // mutator hook might say no
-                                               {
-                                                       if (IS_OBSERVER(caller))
-                                                               TRANSMUTE(Spectator, caller);
-                                               }
+                                                       { }
                                                else
                                                        sprint(caller, "Can't spectate ", argv(1), "^7\n");
                                        }