]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/pathlib/path_waypoint.qc
Merge branch 'master' into terencehill/bot_ai
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / pathlib / path_waypoint.qc
index 35dcce5b25030cad21e169218900308c5c1f6f55..906ebc7a54b1134d4291648da47e58c878b7831c 100644 (file)
@@ -1,5 +1,5 @@
 #include "path_waypoint.qh"
-#include "../bot/waypoints.qh"
+#include "../bot/api.qh"
 
 #include "pathlib.qh"
 #include "main.qh"
@@ -114,20 +114,16 @@ float pathlib_wpp_expand(entity wp)
 
 entity pathlib_wpp_bestopen()
 {
-    entity n, best;
-
     if(best_open_node)
         return best_open_node;
 
-    n = findchainentity(pathlib_list, openlist);
-    best = n;
-    while(n)
-    {
-        if(n.pathlib_node_f < best.pathlib_node_f)
-            best = n;
+    entity best = NULL;
 
-        n = n.chain;
-    }
+    FOREACH_ENTITY_ENT(pathlib_list, openlist,
+    {
+        if(!best || it.pathlib_node_f < best.pathlib_node_f)
+            best = it;
+    });
 
     return best;
 
@@ -135,7 +131,6 @@ entity pathlib_wpp_bestopen()
 
 entity pathlib_waypointpath(entity wp_from, entity wp_to, float callback)
 {
-    entity n;
     float ptime;
 
     ptime                                      = gettime(GETTIME_REALTIME);
@@ -164,32 +159,30 @@ entity pathlib_waypointpath(entity wp_from, entity wp_to, float callback)
     pathlib_searched_cnt     = 0;
     pathlib_foundgoal      = false;
 
-    LOG_TRACE("pathlib_waypointpath init\n");
+    LOG_TRACE("pathlib_waypointpath init");
 
     // Initialize waypoint grid
-    // FIXME! presisted chain for better preformance
-    for(n = findchain(classname, "waypoint"); n; n = n.chain)
+    IL_EACH(g_waypoints, true,
     {
-        n.pathlib_list = NULL;
-        n.pathlib_node_g = 0;
-        n.pathlib_node_f = 0;
-        n.pathlib_node_h = 0;
-
-        //setmodel(n, "models/runematch/rune.mdl");
-        //n.effects = EF_LOWPRECISION;
-        //n.colormod = '0 0 0';
-        //n.scale = 1;
+        it.pathlib_list = NULL;
+        it.pathlib_node_g = 0;
+        it.pathlib_node_f = 0;
+        it.pathlib_node_h = 0;
 
-    }
+        //setmodel(it, "models/runematch/rune.mdl");
+        //it.effects = EF_LOWPRECISION;
+        //it.colormod = '0 0 0';
+        //it.scale = 1;
+    });
 
     goal_node  = wp_to;
     start_node = wp_from;
 
     start_node.pathlib_list = closedlist;
-    LOG_TRACE("Expanding ",ftos(pathlib_wpp_expand(start_node))," links\n");
+    LOG_TRACE("Expanding ",ftos(pathlib_wpp_expand(start_node))," links");
     if(pathlib_open_cnt <= 0)
     {
-        LOG_TRACE("pathlib_waypointpath: Start waypoint not linked! aborting.\n");
+        LOG_TRACE("pathlib_waypointpath: Start waypoint not linked! aborting.");
         return NULL;
     }
 
@@ -203,17 +196,17 @@ entity pathlib_waypointpath_step()
     n = pathlib_wpp_bestopen();
     if(!n)
     {
-        LOG_TRACE("Cannot find best open node, abort.\n");
+        LOG_TRACE("Cannot find best open node, abort.");
         return NULL;
     }
     pathlib_wpp_close(n);
-       LOG_TRACE("Expanding ",ftos(pathlib_wpp_expand(n))," links\n");
+       LOG_TRACE("Expanding ",ftos(pathlib_wpp_expand(n))," links");
 
     if(pathlib_foundgoal)
     {
         entity start, end, open, ln;
 
-        LOG_TRACE("Target found. Rebuilding and filtering path...\n");
+        LOG_TRACE("Target found. Rebuilding and filtering path...");
 
                buildpath_nodefilter = buildpath_nodefilter_none;
                start = path_build(NULL, start_node.origin, NULL, NULL);