From: terencehill <piuntn@gmail.com>
Date: Sun, 16 May 2010 16:28:57 +0000 (+0200)
Subject: Fixed a bug in CA with bot_vs_human active
X-Git-Tag: xonotic-v0.1.0preview~543^2~1
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d0a33a0b02e634b921c68f59195d5902d28ee2e1;p=xonotic%2Fxonotic-data.pk3dir.git

Fixed a bug in CA with bot_vs_human active
When u loose, bots immediately disconnect and don't get the point for the round.
---

diff --git a/qcsrc/server/arena.qc b/qcsrc/server/arena.qc
index 5dd01d4ddf..e68e295022 100644
--- a/qcsrc/server/arena.qc
+++ b/qcsrc/server/arena.qc
@@ -11,6 +11,7 @@ entity champion;
 float warmup;
 float allowed_to_spawn;
 float player_cnt;
+float required_ca_players;
 .float caplayer;
 
 void PutObserverInServer();
@@ -43,7 +44,7 @@ void reset_map(float dorespawn)
 	lms_next_place = player_count;
 
 	race_ReadyRestart();
-	
+
 	for(self = world; (self = nextent(self)); )
 	if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
 	{
@@ -198,7 +199,7 @@ void Arena_Warmup()
 
 	allowed_to_spawn = 0;
 
-	if(g_ca && (player_cnt < 2 || inWarmupStage))
+	if(g_ca && (player_cnt < required_ca_players || inWarmupStage))
 		allowed_to_spawn = 1;
 
 	msg = NEWLINES;
@@ -280,13 +281,15 @@ void Spawnqueue_Check()
 			}
 		}
 
-		if(player_cnt < 2 && (redspawned && bluespawned)) {
+		required_ca_players = max(2, fabs(cvar("bot_vs_human") + 1));
+
+		if(player_cnt < required_ca_players && (redspawned && bluespawned)) {
 			reset_map(TRUE);
 		}
-		else if(player_cnt < 2) {
+		else if(player_cnt < required_ca_players) {
 			FOR_EACH_CLIENT(self) 
 			if(self.classname == "player")
-				centerprint(self, strcat("^1Need at least 2 players to play CA", "^7\n"));
+				centerprint(self, strcat("^1Need at least 1 player in each team to play CA", "^7\n"));
 
 			allowed_to_spawn = 1;
 			return;
diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc
index b428530457..58dc1cf86d 100644
--- a/qcsrc/server/bot/bot.qc
+++ b/qcsrc/server/bot/bot.qc
@@ -527,7 +527,7 @@ void bot_serverframe()
 
 	FOR_EACH_REALCLIENT(head)
 	{
-		if(head.classname == "player" || g_lms || g_arena)
+		if(head.classname == "player" || g_lms || g_arena || g_ca)
 			++activerealplayers;
 		++realplayers;
 	}
diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc
index 7e73ea345b..3a3a8a0d7a 100644
--- a/qcsrc/server/cl_player.qc
+++ b/qcsrc/server/cl_player.qc
@@ -432,7 +432,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
 	else
 		Violence_GibSplash_At(hitloc, force, 2, bound(0, damage, 200) / 16, self, attacker);
 
-	if((g_arena && numspawned < 2) || (g_ca && player_cnt < 2) && !inWarmupStage)
+	if((g_arena && numspawned < 2) || (g_ca && player_cnt < required_ca_players) && !inWarmupStage)
 		return;
 
 	if (!g_minstagib)