From: TimePath Date: Sat, 21 Nov 2015 09:06:49 +0000 (+1100) Subject: CA: fix spectate X-Git-Tag: xonotic-v0.8.2~1646 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9dd0a70198f924213ebe36703e3b4effc56af98a;p=xonotic%2Fxonotic-data.pk3dir.git CA: fix spectate closes #1592 --- diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 4795aab28..5c7c2311b 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -701,6 +701,7 @@ MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars); #define EV_SpectateSet(i, o) \ /**/ i(entity, __self) \ /**/ i(entity, spec_player) \ + /**/ o(entity, spec_player) \ /**/ entity spec_player; MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet); @@ -708,12 +709,14 @@ MUTATOR_HOOKABLE(SpectateSet, EV_SpectateSet); #define EV_SpectateNext(i, o) \ /**/ i(entity, __self) \ /**/ i(entity, spec_player) \ + /**/ o(entity, spec_player) \ /**/ MUTATOR_HOOKABLE(SpectateNext, EV_SpectateNext); #define EV_SpectatePrev(i, o) \ /**/ i(entity, __self) \ /**/ i(entity, spec_player) \ + /**/ o(entity, spec_player) \ /**/ i(entity, spec_first) \ /**/ entity spec_first; diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 725569bff..9b9c8a05b 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -202,28 +202,24 @@ float ca_isEliminated(entity e) return false; } -// Returns next available player to spectate if g_ca_spectate_enemies == 0 +/** Returns next available player to spectate if g_ca_spectate_enemies == 0 */ entity CA_SpectateNext(entity player, entity start) { - if(SAME_TEAM(start, player)) - return start; - - entity spec_other = start; + if (SAME_TEAM(start, player)) return start; // continue from current player - while(spec_other && DIFF_TEAM(spec_other, player)) - spec_other = find(spec_other, classname, "player"); - - if (!spec_other) + for (entity e = start; (e = find(e, classname, "player")); ) { - // restart from begining - spec_other = find(spec_other, classname, "player"); - while(spec_other && DIFF_TEAM(spec_other, player)) - spec_other = find(spec_other, classname, "player"); + if (SAME_TEAM(player, e)) return e; } - - return spec_other; + // restart from begining + for (entity e = NULL; (e = find(e, classname, "player")); ) + { + if (SAME_TEAM(player, e)) return e; + } + return start; } + MUTATOR_HOOKFUNCTION(ca, PlayerSpawn) {SELFPARAM(); self.caplayer = 1;