]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/gamemodes/gamemode/clanarena/sv_clanarena.qc
Merge branch 'master' into pending-release
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / gamemodes / gamemode / clanarena / sv_clanarena.qc
index d64ce3604a293b4221d21ab5c1de21da31a32bac..7a16141fc8ebbe89409b947cdfd9b979da571233 100644 (file)
@@ -1,7 +1,6 @@
 #include "sv_clanarena.qh"
 
 float autocvar_g_ca_damage2score = 100;
-bool autocvar_g_ca_spectate_enemies;
 bool autocvar_g_ca_prevent_stalemate;
 
 float autocvar_g_ca_start_health = 200;
@@ -275,6 +274,11 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer)
 
 MUTATOR_HOOKFUNCTION(ca, reset_map_players)
 {
+       g_ca_spectate_enemies = autocvar_g_ca_spectate_enemies;
+       observe_blocked_if_eliminated = (g_ca_spectate_enemies == -1);
+       // we can avoid sending observe_blocked_if_eliminated to all clients here (with ClientData_Touch)
+       // since it will get sent whenever the client spectates someone anyway
+
        FOREACH_CLIENT(true, {
                CS(it).killcount = 0;
                if (INGAME(it) || IS_BOT_CLIENT(it))
@@ -367,7 +371,10 @@ MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver)
                INGAME_STATUS_CLEAR(player);
        }
        if (INGAME(player))
+       {
                player.frags = FRAGS_PLAYER_OUT_OF_GAME;
+               player.would_spectate = observe_blocked_if_eliminated; // if blocked from observing force to spectate now
+       }
        if (!warmup_stage)
                eliminatedPlayers.SendFlags |= 1;
        if (!INGAME(player))
@@ -508,7 +515,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectateSet)
        entity client = M_ARGV(0, entity);
        entity targ = M_ARGV(1, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && INGAME(client))
+       if (g_ca_spectate_enemies != 1 && INGAME(client))
        if (DIFF_TEAM(targ, client))
                return true;
 }
@@ -517,7 +524,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectateNext)
 {
        entity client = M_ARGV(0, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && INGAME(client)
+       if (g_ca_spectate_enemies != 1 && INGAME(client)
                && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
        {
                entity targ = M_ARGV(1, entity);
@@ -532,7 +539,7 @@ MUTATOR_HOOKFUNCTION(ca, SpectatePrev)
        entity targ = M_ARGV(1, entity);
        entity first = M_ARGV(2, entity);
 
-       if (!autocvar_g_ca_spectate_enemies && INGAME(client)
+       if (g_ca_spectate_enemies != 1 && INGAME(client)
                && Team_GetNumberOfAlivePlayers(Entity_GetTeam(client)))
        {
                do { targ = targ.chain; }