From bc464cf995b26a55ceab9c6bab4a83f7a65701fe Mon Sep 17 00:00:00 2001
From: terencehill <piuntn@gmail.com>
Date: Mon, 2 Jan 2012 00:05:30 +0100
Subject: [PATCH] Avoid counting another time players of each CA team when
 detecting if teams are ok (thanks to the previous commit we can call the code
 to count players before Arena_Warmup)

---
 qcsrc/server/arena.qc   | 19 ++-----------------
 qcsrc/server/sv_main.qc |  3 +++
 2 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/qcsrc/server/arena.qc b/qcsrc/server/arena.qc
index 6eaff6b795..2f85d0d712 100644
--- a/qcsrc/server/arena.qc
+++ b/qcsrc/server/arena.qc
@@ -269,18 +269,8 @@ void Arena_Warmup()
 		FOR_EACH_PLAYER(e)
 			Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
 
-		if(g_ca) {
-			float start_red_ca_players, start_blue_ca_players;
-
-			FOR_EACH_PLAYER(e) {
-				if (e.team == COLOR_TEAM1)
-					start_red_ca_players += 1;
-				else if (e.team == COLOR_TEAM2)
-					start_blue_ca_players += 1;
-			}
-			// teams are ok if there's at least 1 player in each team
-			ca_teams_ok = (start_red_ca_players && start_blue_ca_players);
-		}
+		if(g_ca)
+			ca_teams_ok = (red_players && blue_players); // teams are ok if there's at least 1 player in each team
 
 		FOR_EACH_PLAYER(e)
 		{
@@ -389,11 +379,6 @@ void count_alive_players()
 float warntime;
 void Spawnqueue_Check()
 {
-	count_players();
-	if(g_ca || g_freezetag) // we want to perform this before the return block below (CA)...
-	{
-		count_alive_players();
-	}
 	if(time < warmup + 1 || inWarmupStage || intermission_running)
 		return;
 
diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc
index 2497b9d502..16678e6774 100644
--- a/qcsrc/server/sv_main.qc
+++ b/qcsrc/server/sv_main.qc
@@ -201,6 +201,9 @@ void StartFrame (void)
 
 	skill = autocvar_skill;
 
+	count_players();
+	if(g_ca || g_freezetag)
+		count_alive_players();
 	Arena_Warmup();
 	Spawnqueue_Check();
 
-- 
2.39.5