From: terencehill Date: Thu, 7 Jul 2011 17:49:06 +0000 (+0200) Subject: Fix a bug in CA where if the round starts with one player in each team and one player... X-Git-Tag: xonotic-v0.6.0~40^2~141^2~1^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=01e79c17c82c10622708fb4e2ce2efc818d1a0ef;p=xonotic%2Fxonotic-data.pk3dir.git Fix a bug in CA where if the round starts with one player in each team and one player switches team, the next rounds start anyway and are won immediately by the team with players. The previous code worked only when teams are autobalanced. --- diff --git a/qcsrc/server/arena.qc b/qcsrc/server/arena.qc index 06492be2f..09db36618 100644 --- a/qcsrc/server/arena.qc +++ b/qcsrc/server/arena.qc @@ -10,8 +10,7 @@ entity spawnqueue_last; entity champion; string champion_name; float warmup; -float ca_players; -float required_ca_players; +float ca_teams_ok; .float caplayer; void PutObserverInServer(); @@ -218,7 +217,7 @@ void Arena_Warmup() if(inWarmupStage) allowed_to_spawn = 1; - if(ca_players < required_ca_players) + if(g_ca && !ca_teams_ok) allowed_to_spawn = 1; msg = NEWLINES; @@ -264,10 +263,16 @@ void Arena_Warmup() centerprint(self, "^1Begin!\n"); if(g_ca) { - ca_players = 0; + float start_red_ca_players, start_blue_ca_players; - FOR_EACH_PLAYER(e) - ca_players += 1; + 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(self.classname == "player" && self.health > 0 && self.movetype == MOVETYPE_NONE) @@ -378,12 +383,10 @@ void Spawnqueue_Check() return; if(g_ca) { - required_ca_players = max(2, fabs(autocvar_bot_vs_human + 1)); - - if(ca_players < required_ca_players && (red_players && blue_players)) { + if(!ca_teams_ok && (red_players && blue_players)) { reset_map(TRUE); } - else if(ca_players < required_ca_players) { + else if(!ca_teams_ok) { FOR_EACH_PLAYER(self) centerprint(self, strcat("^1Need at least 1 player in each team to play CA", "^7\n")); return; diff --git a/qcsrc/server/cl_player.qc b/qcsrc/server/cl_player.qc index 0ba5f1d10..41f9576e3 100644 --- a/qcsrc/server/cl_player.qc +++ b/qcsrc/server/cl_player.qc @@ -388,7 +388,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht float valid_damage_for_weaponstats; float excess; - if((g_arena && numspawned < 2) || (g_ca && ca_players < required_ca_players) && !inWarmupStage) + if((g_arena && numspawned < 2) || (g_ca && !ca_teams_ok) && !inWarmupStage) return; dh = max(self.health, 0);