]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix a stupid loop
authorMario <mario@smbclan.net>
Thu, 24 Dec 2015 02:01:22 +0000 (12:01 +1000)
committerMario <mario@smbclan.net>
Thu, 24 Dec 2015 02:01:22 +0000 (12:01 +1000)
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc

index 4d6b5631ae9b2691635dbd43a4e2609cddd96109..50ab4d6b4a4817b10e354f3c88e021f82d9fa364 100644 (file)
@@ -1399,7 +1399,7 @@ void havocbot_role_ons_setrole(entity bot, int role)
 
 void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 {SELFPARAM();
-       entity cp, cp1, cp2, best, pl, wp;
+       entity cp, cp1, cp2, best, wp;
        float radius, bestvalue;
        int c;
        bool found;
@@ -1419,11 +1419,12 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 
                // Count team mates interested in this control point
                // (easier and cleaner than keeping counters per cp and teams)
-               FOR_EACH_PLAYER(pl)
-               if(SAME_TEAM(pl, self))
-               if(pl.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE)
-               if(pl.havocbot_ons_target==cp2)
-                       ++c;
+               FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
+                       if(SAME_TEAM(it, self))
+                       if(it.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE)
+                       if(it.havocbot_ons_target == cp2)
+                               ++c;
+               ));
 
                // NOTE: probably decrease the cost of attackable control points
                cp2.wpcost = c;
@@ -1618,9 +1619,6 @@ void havocbot_role_ons_defense()
 
 void havocbot_ons_reset_role(entity bot)
 {SELFPARAM();
-       entity head;
-       int c = 0;
-
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -1628,18 +1626,6 @@ void havocbot_ons_reset_role(entity bot)
 
        // TODO: Defend control points or generator if necessary
 
-       // if there is only me on the team switch to offense
-       c = 0;
-       FOR_EACH_PLAYER(head)
-       if(SAME_TEAM(head, self))
-               ++c;
-
-       if(c==1)
-       {
-               havocbot_role_ons_setrole(bot, HAVOCBOT_ONS_ROLE_OFFENSE);
-               return;
-       }
-
        havocbot_role_ons_setrole(bot, HAVOCBOT_ONS_ROLE_OFFENSE);
 }