]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Freezetag: update player count before checking it, besides making the code more intui...
authorterencehill <piuntn@gmail.com>
Mon, 3 Dec 2012 23:20:20 +0000 (00:20 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 3 Dec 2012 23:37:52 +0000 (00:37 +0100)
qcsrc/server/arena.qc
qcsrc/server/mutators/gamemode_freezetag.qc

index 6f38c45698389c17a9c0528245cb64df45dab246..a4968af8031574a614df744f0c0231c716cc114f 100644 (file)
@@ -439,16 +439,13 @@ void Arena_Main()
        if(!(g_ca || g_freezetag || g_arena))
                return;
 
-       if(g_ca || g_freezetag)
+       if(g_ca)
        {
                count_players();
-               if(g_ca)
-                       count_alive_players();
-               Arena_Warmup();
+               count_alive_players();
        }
-       else if(arena_roundbased)
+       if(!g_arena || arena_roundbased)
                Arena_Warmup();
-
        Spawnqueue_Check();
 }
 
index efc3d8f9d58200d405600b53013036d1f45032d9..ca453c5c0145fe3023927620dda8221835884733 100644 (file)
@@ -74,12 +74,28 @@ void freezetag_Ice_Think()
 void freezetag_count_alive_players()
 {
        entity e;
-       redalive = bluealive = yellowalive = pinkalive = 0;
+       total_players = redalive = bluealive = yellowalive = pinkalive = 0;
        FOR_EACH_PLAYER(e) {
-               if(e.team == COLOR_TEAM1 && e.freezetag_frozen == 0 && e.health >= 1) ++redalive;
-               else if(e.team == COLOR_TEAM2 && e.freezetag_frozen == 0 && e.health >= 1) ++bluealive;
-               else if(e.team == COLOR_TEAM3 && e.freezetag_frozen == 0 && e.health >= 1) ++yellowalive;
-               else if(e.team == COLOR_TEAM4 && e.freezetag_frozen == 0 && e.health >= 1) ++pinkalive;
+               if(e.team == COLOR_TEAM1 && e.health >= 1)
+               {
+                       ++total_players;
+                       if (!e.freezetag_frozen) ++redalive;
+               }
+               else if(e.team == COLOR_TEAM2 && e.health >= 1)
+               {
+                       ++total_players;
+                       if (!e.freezetag_frozen) ++bluealive;
+               }
+               else if(e.team == COLOR_TEAM3 && e.health >= 1)
+               {
+                       ++total_players;
+                       if (!e.freezetag_frozen) ++yellowalive;
+               }
+               else if(e.team == COLOR_TEAM4 && e.health >= 1)
+               {
+                       ++total_players;
+                       if (!e.freezetag_frozen) ++pinkalive;
+               }
        }
        FOR_EACH_REALCLIENT(e) {
                e.redalive_stat = redalive;
@@ -146,8 +162,6 @@ void freezetag_Unfreeze(entity attacker)
        self.freezetag_frozen_timeout = 0;
        self.freezetag_revive_progress = 0;
 
-       freezetag_count_alive_players();
-
        // remove the ice block
        entity ice;
        for(ice = world; (ice = find(ice, classname, "freezetag_ice")); ) if(ice.owner == self)
@@ -275,7 +289,9 @@ MUTATOR_HOOKFUNCTION(freezetag_RemovePlayer)
        self.health = 0; // neccessary to update correctly alive stats
        freezetag_Unfreeze(world);
 
-       if(total_players > 2) // only check for winners if we had more than two players (one of them left, don't let the other player win just because of that)
+       freezetag_count_alive_players();
+
+       if(total_players > 1) // only check for winners if we had more than two players (one of them left, don't let the other player win just because of that)
                freezetag_CheckWinner();
 
        return 1;
@@ -336,10 +352,10 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerSpawn)
        if(self.freezetag_frozen) // stay frozen if respawning after death (DEATH_HURTTRIGGER)
                return 1;
 
-       if(time <= game_starttime || inWarmupStage || total_players == 0)
+       if(time <= game_starttime || inWarmupStage || total_players == 1)
                return 1;
 
-       if(total_players == 1) // only one player active on server, start a new match immediately
+       if(total_players == 2) // only one player active on server, start a new match immediately
        if(!next_round && warmup && (time < warmup - autocvar_g_freezetag_warmup || time > warmup)) // not awaiting next round
        {
                next_round = time;
@@ -398,6 +414,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
                {
                        self.health = autocvar_g_balance_health_start;
                        freezetag_Unfreeze(world);
+                       freezetag_count_alive_players();
                        return 1;
                }
        }
@@ -433,6 +450,7 @@ MUTATOR_HOOKFUNCTION(freezetag_PlayerPreThink)
                if(self.freezetag_revive_progress >= 1)
                {
                        freezetag_Unfreeze(self);
+                       freezetag_count_alive_players();
 
                        // EVERY team mate nearby gets a point (even if multiple!)
                        FOR_EACH_PLAYER(other) if(self != other)