r2464 - trunk/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu May 3 12:59:33 EDT 2007


Author: div0
Date: 2007-05-03 12:59:33 -0400 (Thu, 03 May 2007)
New Revision: 2464

Modified:
   trunk/data/qcsrc/server/teamplay.qc
Log:
forced team balance: use smallest team count as reference


Modified: trunk/data/qcsrc/server/teamplay.qc
===================================================================
--- trunk/data/qcsrc/server/teamplay.qc	2007-05-03 16:46:11 UTC (rev 2463)
+++ trunk/data/qcsrc/server/teamplay.qc	2007-05-03 16:59:33 UTC (rev 2464)
@@ -1117,7 +1117,7 @@
 	}
 	else
 	{
-		if(1+floor(howmany_toomany) < cvar("g_balance_teams_complain"))
+		if(howmany_toomany < cvar("g_balance_teams_complain"))
 			return;
 		if(time < lastRebalanceInfo + 90)
 			return;
@@ -1147,7 +1147,7 @@
 // sure they're more or less balanced in player count.
 void AuditTeams()
 {
-	float numplayers, numteams, toomany;
+	float numplayers, numteams, smallest, toomany;
 	float balance;
 	balance = IsTeamBalanceForced();
 	if(balance == 0)
@@ -1164,26 +1164,33 @@
 	GetTeamCounts(world);
 
 
-	numteams = numplayers = 0;
+	numteams = numplayers = smallest = 0;
 	if(c1 >= 0)
 	{
 		numteams = numteams + 1;
 		numplayers = numplayers + c1;
+		smallest = c1;
 	}
 	if(c2 >= 0)
 	{
 		numteams = numteams + 1;
 		numplayers = numplayers + c2;
+		if(c2 < smallest)
+			smallest = c2;
 	}
 	if(c3 >= 0)
 	{
 		numteams = numteams + 1;
 		numplayers = numplayers + c3;
+		if(c3 < smallest)
+			smallest = c3;
 	}
 	if(c4 >= 0)
 	{
 		numteams = numteams + 1;
 		numplayers = numplayers + c4;
+		if(c4 < smallest)
+			smallest = c4;
 	}
 
 	if(numplayers <= 0)
@@ -1191,18 +1198,15 @@
 	if(numteams < 2)
 		return; // don't bother shuffling if for some reason there aren't any teams
 
-	toomany = (numplayers / numteams) + 1;
+	toomany = smallest + 1;
 
-	if(toomany <= 0)
-		return; // that's weird...
-
-	if(c1 && c1 >= toomany)
+	if(c1 && c1 > toomany)
 		CauseRebalance(1, c1 - toomany);
-	if(c2 && c2 >= toomany)
+	if(c2 && c2 > toomany)
 		CauseRebalance(2, c2 - toomany);
-	if(c3 && c3 >= toomany)
+	if(c3 && c3 > toomany)
 		CauseRebalance(3, c3 - toomany);
-	if(c4 && c4 >= toomany)
+	if(c4 && c4 > toomany)
 		CauseRebalance(4, c4 - toomany);
 
 	// if teams are still unbalanced, balance them further in the next audit,




More information about the nexuiz-commits mailing list