]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix a bug in CA where if the round starts with one player in each team and one player...
authorterencehill <piuntn@gmail.com>
Thu, 7 Jul 2011 17:49:06 +0000 (19:49 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 8 Jul 2011 14:40:39 +0000 (16:40 +0200)
The previous code worked only when teams are autobalanced.

qcsrc/server/arena.qc
qcsrc/server/cl_player.qc

index 06492be2fb92fd68466db416962f7bd2e839e7bc..09db36618aeae5934dffe40dcf4eb29263632b2e 100644 (file)
@@ -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;
index 0ba5f1d1055d68605fe6e117585c5e4257dd7fe0..41f9576e3e51ed09fbf97f730115f55409e66e3b 100644 (file)
@@ -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);