]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Spectate next player if the spectated player becomes observer (very useful in CA...
authorterencehill <piuntn@gmail.com>
Mon, 4 Jun 2018 16:31:17 +0000 (18:31 +0200)
committerterencehill <piuntn@gmail.com>
Mon, 4 Jun 2018 16:31:17 +0000 (18:31 +0200)
qcsrc/server/client.qc

index 06aac36e774b659e4983a1f9578112bcd6ed03fe..270a4d1af3c4940da7a1102c5286e5bca81b80d7 100644 (file)
@@ -2302,6 +2302,7 @@ bool PlayerThink(entity this)
        return true;
 }
 
+.bool would_spectate;
 void ObserverThink(entity this)
 {
        if ( CS(this).impulse )
@@ -2314,7 +2315,7 @@ void ObserverThink(entity this)
                if (PHYS_INPUT_BUTTON_JUMP(this) && joinAllowed(this)) {
                        this.flags &= ~FL_JUMPRELEASED;
                        this.flags |= FL_SPAWNING;
-               } else if(PHYS_INPUT_BUTTON_ATCK(this) && !CS(this).version_mismatch) {
+               } else if(PHYS_INPUT_BUTTON_ATCK(this) && !CS(this).version_mismatch || this.would_spectate) {
                        this.flags &= ~FL_JUMPRELEASED;
                        if(SpectateNext(this)) {
                                TRANSMUTE(Spectator, this);
@@ -2374,12 +2375,19 @@ void SpectatorThink(entity this)
                        }
                        CS(this).impulse = 0;
                } else if (PHYS_INPUT_BUTTON_ATCK2(this)) {
+                       this.would_spectate = false;
                        this.flags &= ~FL_JUMPRELEASED;
                        TRANSMUTE(Observer, this);
                        PutClientInServer(this);
                } else {
                        if(!SpectateUpdate(this))
-                               PutObserverInServer(this);
+                       {
+                               if(!SpectateNext(this))
+                               {
+                                       PutObserverInServer(this);
+                                       this.would_spectate = true;
+                               }
+                       }
                }
        } else {
                if (!(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this))) {