From 7afcbb39433ed2a94c33c820f2ace04b42fc5a8b Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 13 Apr 2013 22:39:27 +0200 Subject: [PATCH] Superspec mutator shouldn't call SpectateNext as it may lead to spectate an unwanted player in CA since players of the same team cannot be spectated --- qcsrc/server/cl_client.qc | 86 ++++++++++++---------- qcsrc/server/mutators/mutator_superspec.qc | 2 +- 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 4c7d5c575..8d84988b4 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2192,6 +2192,46 @@ float SpectateUpdate() { } +float setSpectator() +{ + if(self.enemy.classname != "player") + return FALSE; + /*if(self.enemy.vehicle) + { + + msg_entity = self; + WriteByte(MSG_ONE, SVC_SETVIEW); + WriteEntity(MSG_ONE, self.enemy); + //stuffcmd(self, "set viewsize $tmpviewsize \n"); + + self.movetype = MOVETYPE_NONE; + accuracy_resend(self); + } + else + {*/ + msg_entity = self; + WriteByte(MSG_ONE, SVC_SETVIEW); + WriteEntity(MSG_ONE, self.enemy); + //stuffcmd(self, "set viewsize $tmpviewsize \n"); + self.movetype = MOVETYPE_NONE; + accuracy_resend(self); + + if(!SpectateUpdate()) + PutObserverInServer(); + //} + return TRUE; +} + +float Spectate(entity pl) +{ + if(g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) + if(pl.team != self.team) + return 0; + + self.enemy = pl; + return setSpectator(); +} + // Returns next available player to spectate if g_ca_spectate_enemies == 0 entity CA_SpectateNext(entity start) { if (start.team == self.team) { @@ -2215,13 +2255,10 @@ entity CA_SpectateNext(entity start) { return other; } -float SpectateNext(entity _prefer) { - - if(_prefer) - other = _prefer; - else - other = find(self.enemy, classname, "player"); - +float SpectateNext() +{ + other = find(self.enemy, classname, "player"); + if (g_ca && !autocvar_g_ca_spectate_enemies && self.caplayer) { // CA and ca players when spectating enemies is forbidden other = CA_SpectateNext(other); @@ -2230,38 +2267,11 @@ float SpectateNext(entity _prefer) { if (!other) other = find(other, classname, "player"); } - + if (other) self.enemy = other; - if(self.enemy.classname == "player") { - /*if(self.enemy.vehicle) - { - - msg_entity = self; - WriteByte(MSG_ONE, SVC_SETVIEW); - WriteEntity(MSG_ONE, self.enemy); - //stuffcmd(self, "set viewsize $tmpviewsize \n"); - - self.movetype = MOVETYPE_NONE; - accuracy_resend(self); - } - else - {*/ - msg_entity = self; - WriteByte(MSG_ONE, SVC_SETVIEW); - WriteEntity(MSG_ONE, self.enemy); - //stuffcmd(self, "set viewsize $tmpviewsize \n"); - self.movetype = MOVETYPE_NONE; - accuracy_resend(self); - - if(!SpectateUpdate()) - PutObserverInServer(); - //} - return 1; - } else { - return 0; - } + return setSpectator(); } /* @@ -2419,7 +2429,7 @@ void ObserverThink() self.flags |= FL_SPAWNING; } else if(self.BUTTON_ATCK && !self.version_mismatch) { self.flags &~= FL_JUMPRELEASED; - if(SpectateNext(world) == 1) { + if(SpectateNext()) { self.classname = "spectator"; } } else { @@ -2450,7 +2460,7 @@ void SpectatorThink() self.flags |= FL_SPAWNING; } else if(self.BUTTON_ATCK) { self.flags &~= FL_JUMPRELEASED; - if(SpectateNext(world) == 1) { + if(SpectateNext()) { self.classname = "spectator"; } else { self.classname = "observer"; diff --git a/qcsrc/server/mutators/mutator_superspec.qc b/qcsrc/server/mutators/mutator_superspec.qc index a351f937c..16aa80cab 100644 --- a/qcsrc/server/mutators/mutator_superspec.qc +++ b/qcsrc/server/mutators/mutator_superspec.qc @@ -21,7 +21,7 @@ float _spectate(entity _player) { - if(SpectateNext(_player) == 1) + if(Spectate(_player) == 1) { PutObserverInServer(); self.classname = "spectator"; -- 2.39.2