From: terencehill <piuntn@gmail.com>
Date: Mon, 20 Sep 2010 16:35:11 +0000 (+0200)
Subject: Other minor fixes of bot_vs_human:
X-Git-Tag: xonotic-v0.1.0preview~308^2^2~4^2~2
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4cacb380f3897d778cd991938511e39d5610c2e4;p=xonotic%2Fxonotic-data.pk3dir.git

Other minor fixes of bot_vs_human:
- Always check for available teams before reading bot_vs_human value, as it works only in games with 2 teams
- Do not read bot_join_empty and minplayers cvars when bot_vs_human is active, they are incompatible with it
- disable team nagger when bot_vs_human is active
---

diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc
index 3ef50481d..a629b95a1 100644
--- a/qcsrc/server/bot/bot.qc
+++ b/qcsrc/server/bot/bot.qc
@@ -555,17 +555,16 @@ void bot_serverframe()
 	// But don't remove bots immediately on level change, as the real players
 	// usually haven't rejoined yet
 	bots_would_leave = FALSE;
-	if ((realplayers || cvar("bot_join_empty") || (currentbots > 0 && time < 5)))
+	if (teamplay && cvar("bot_vs_human") && (c3==-1 && c4==-1))
+		bots = min(ceil(fabs(cvar("bot_vs_human")) * activerealplayers), maxclients - realplayers);
+	else if ((realplayers || cvar("bot_join_empty") || (currentbots > 0 && time < 5)))
 	{
 		float realminplayers, minplayers;
 		realminplayers = cvar("minplayers");
 		minplayers = max(0, floor(realminplayers));
 
 		float realminbots, minbots;
-		if(teamplay && cvar("bot_vs_human"))
-			realminbots = ceil(fabs(cvar("bot_vs_human")) * activerealplayers);
-		else
-			realminbots = cvar("bot_number");
+		realminbots = cvar("bot_number");
 		minbots = max(0, floor(realminbots));
 
 		bots = min(max(minbots, minplayers - activerealplayers), maxclients - realplayers);
diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc
index 9b53a1d95..ac33ddc50 100644
--- a/qcsrc/server/cl_client.qc
+++ b/qcsrc/server/cl_client.qc
@@ -1593,7 +1593,7 @@ void ClientConnect (void)
 			race_SendRankings(i, 0, 0, MSG_ONE);
 		}
 	}
-	else if(cvar("sv_teamnagger") && !g_ca) // teamnagger is currently bad for ca
+	else if(cvar("sv_teamnagger") && !(cvar("bot_vs_human") && (c3==-1 && c4==-1)) && !g_ca) // teamnagger is currently bad for ca
 		send_CSQC_teamnagger();
 
 	CheatInitClient();
diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc
index 0798b29b2..ce7402f8d 100644
--- a/qcsrc/server/teamplay.qc
+++ b/qcsrc/server/teamplay.qc
@@ -16,6 +16,8 @@ float IsTeamBalanceForced()
 		return 0;
 	if(cvar("g_campaign"))
 		return 0;
+	if(cvar("bot_vs_human") && (c3==-1 && c4==-1))
+		return 0;
 	if(!cvar("g_balance_teams_force"))
 		return -1;
 	return 1;
@@ -694,7 +696,7 @@ void CheckAllowedTeams (entity for_whom)
 	}
 
 	// TODO: Balance quantity of bots across > 2 teams when bot_vs_human is set (and remove next line)
-	if(c3==-1&&c4==-1)
+	if(c3==-1 && c4==-1)
 	if(cvar("bot_vs_human") && for_whom)
 	{
 		if(cvar("bot_vs_human") > 0)
@@ -799,7 +801,7 @@ float FindSmallestTeam(entity pl, float ignore_pl)
 	if(c4 >= 0)
 		totalteams = totalteams + 1;
 
-	if(cvar("bot_vs_human"))
+	if(cvar("bot_vs_human") && totalteams == 1)
 		totalteams += 1;
 
 	if(totalteams <= 1)