r2473 - branches/nexuiz-2.0/data/qcsrc/server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu May 3 17:16:05 EDT 2007


Author: div0
Date: 2007-05-03 17:16:05 -0400 (Thu, 03 May 2007)
New Revision: 2473

Modified:
   branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc
   branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc
Log:
various minor fixes


Modified: branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc	2007-05-03 21:15:40 UTC (rev 2472)
+++ branches/nexuiz-2.0/data/qcsrc/server/keyhunt.qc	2007-05-03 21:16:05 UTC (rev 2473)
@@ -399,6 +399,9 @@
 
 void kh_Key_Touch()
 {
+	if(intermission_running)
+		return;
+
 	if(self.owner) // already carried
 		return;
 	if(other.classname != "player")
@@ -415,6 +418,9 @@
 {
 	entity head;
 
+	if(intermission_running)
+		return;
+
 #ifdef KH_KEY_ATTACHMENT_DEBUG
 	if(self.kh_prev == self.owner)
 	{
@@ -552,11 +558,11 @@
 	{
 		kh_Scores_Event(attacker, world, "push", cvar("g_balance_keyhunt_score_push"), 0);
 		centerprint(attacker, "Your push is the best!\n\n\n");
-		bprint("The ", ColoredTeamName(teem), "^7 could not take care of the ", lostkey.netname, "\n");
+		bprint("The ", ColoredTeamName(teem), "^7 could not take care of the ", lostkey.netname, " when ", attacker.netname, "^7 came.\n");
 	}
 	else
 	{
-		float of, fragsleft, i, thisteam;
+		float of, fragsleft, i, j, thisteam;
 		of = cvar("g_balance_keyhunt_score_destroyed_ownfactor");
 
 		FOR_EACH_PLAYER(player)
@@ -576,16 +582,20 @@
 		fragsleft = DistributeEvenly_Get(players);
 
 		// Now distribute these among all other teams...
+		j = kh_teams - 1;
 		for(i = 0; i < kh_teams; ++i)
 		{
 			thisteam = kh_Team_ByID(i);
+			if(thisteam == teem) // bad boy, no cookie - this WILL happen
+				continue;
+
 			players = 0;
 			FOR_EACH_PLAYER(player)
 				if(player.team == thisteam)
 					++players;
 
-			DistributeEvenly_Init(fragsleft, kh_teams - i);
-			fragsleft = DistributeEvenly_Get(kh_teams - i - 1);
+			DistributeEvenly_Init(fragsleft, j);
+			fragsleft = DistributeEvenly_Get(j - 1);
 			DistributeEvenly_Init(DistributeEvenly_Get(1), players);
 
 			FOR_EACH_PLAYER(player)
@@ -611,10 +621,12 @@
 	kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round"), "Round starts in ", kh_StartRound);
 }
 
-float kh_EnoughPlayers()
+string kh_CheckEnoughPlayers()
 {
 	float i, players, teem;
 	entity player;
+	string result;
+	result = "";
 	
 	// find a random player per team
 	for(i = 0; i < kh_teams; ++i)
@@ -627,27 +639,35 @@
 					if(player.team == teem)
 						++players;
 		if(players == 0)
-			return FALSE;
+		{
+			if(result != "")
+				result = strcat(result, ", ");
+			result = strcat(result, ColoredTeamName(teem));
+		}
 	}
-	return TRUE;
+	return result;
 }
 
 void kh_WaitForPlayers()
 {
-	if(kh_EnoughPlayers())
+	string teams_missing;
+	teams_missing = kh_CheckEnoughPlayers();
+	if(teams_missing == "")
 		kh_Controller_SetThink(cvar("g_balance_keyhunt_delay_round"), "Round starts in ", kh_StartRound);
 	else
-		kh_Controller_SetThink(1, "Waiting for players to join...", kh_WaitForPlayers);
+		kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), kh_WaitForPlayers);
 }
 
 void kh_StartRound()
 {
+	string teams_missing;
 	float i, players, teem;
 	entity player;
 
-	if(!kh_EnoughPlayers())
+	teams_missing = kh_CheckEnoughPlayers();
+	if(teams_missing != "")
 	{
-		kh_Controller_SetThink(1, "Waiting for players to join...", kh_WaitForPlayers);
+		kh_Controller_SetThink(1, strcat("Waiting for players to join...\n\nNeed active players for: ", teams_missing), kh_WaitForPlayers);
 		return;
 	}
 

Modified: branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc
===================================================================
--- branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc	2007-05-03 21:15:40 UTC (rev 2472)
+++ branches/nexuiz-2.0/data/qcsrc/server/teamplay.qc	2007-05-03 21:16:05 UTC (rev 2473)
@@ -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