]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize code
authorterencehill <piuntn@gmail.com>
Sat, 22 Aug 2015 12:06:23 +0000 (14:06 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 22 Aug 2015 12:06:23 +0000 (14:06 +0200)
qcsrc/server/bot/havocbot/havocbot.qc

index 7b7c6474307a9c81db7cceaaa5eac771420db6c1..3036012754c8fcacce0ed5c9904312c30e5a9ecc 100644 (file)
@@ -910,6 +910,7 @@ void havocbot_chooseenemy()
 
        bool scan_transparent = false;
        bool scan_secondary_targets = false;
+       bool have_secondary_targets = false;
        while(true)
        {
                scan_secondary_targets = false;
@@ -918,7 +919,10 @@ void havocbot_chooseenemy()
                        if(!scan_secondary_targets)
                        {
                                if(head.classname == "misc_breakablemodel")
+                               {
+                                       have_secondary_targets = true;
                                        continue;
+                               }
                        }
                        else
                        {
@@ -940,9 +944,10 @@ void havocbot_chooseenemy()
                                }
                        }
 
-                       if(!best && !scan_secondary_targets)
+                       if(!best && have_secondary_targets && !scan_secondary_targets)
                        {
                                scan_secondary_targets = true;
+                               // restart the loop
                                head = head2;
                                bestrating = 100000000;
                        }