]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/pathlib/expandnode.qc
Merge branch 'master' into terencehill/bot_waypoints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / pathlib / expandnode.qc
index a08c66b3ae5f48fd657adf5ee61ac53282177c92..b77736b19ad7c098c5ab3a0c8bf9dfeb7ba2f76c 100644 (file)
@@ -1,17 +1,19 @@
+#include "expandnode.qh"
+#include "pathlib.qh"
+#include "utility.qh"
+
 vector plib_points2[8];
 vector plib_points[8];
 float  plib_fvals[8];
 
 float pathlib_expandnode_starf(entity node, vector start, vector goal)
 {
-    vector where,f,r,t;
-    float i,fc,fc2,c;
-    entity nap;
+    float fc;
 
-    where = node.origin;
+    vector where = node.origin;
 
-    f = PLIB_FORWARD * pathlib_gridsize;
-    r = PLIB_RIGHT   * pathlib_gridsize;
+    vector f = PLIB_FORWARD * pathlib_gridsize;
+    vector r = PLIB_RIGHT   * pathlib_gridsize;
 
     // Forward
     plib_points[0] = where + f;
@@ -37,9 +39,9 @@ float pathlib_expandnode_starf(entity node, vector start, vector goal)
     // Back-left
     plib_points[7] = where - f - r;
 
-    for(i=0;i < 8; ++i)
+    for(int i=0;i < 8; ++i)
     {
-        t = plib_points[i];
+        vector t = plib_points[i];
         fc  = pathlib_heuristic(t,goal) + pathlib_cost(node, t, pathlib_gridsize);
         plib_fvals[i] = fc;
 
@@ -49,16 +51,18 @@ float pathlib_expandnode_starf(entity node, vector start, vector goal)
     plib_points2[0] = plib_points[0];
     vector bp;
     bp = plib_points[0];
-    fc2 = 0;
-    for(i = 0; i < 8; ++i)
+    int fc2 = 0;
+    for(int i = 0; i < 8; ++i)
     {
-        c = 0;
-        nap = pathlib_nodeatpoint(plib_points[i]);
+        bool c = false;
+        entity nap = pathlib_nodeatpoint(plib_points[i]);
         if(nap)
+        {
             if(nap.owner == openlist)
-                c = 1;
+                c = true;
+        }
         else
-            c = 1;
+            c = true;
 
         if(c)
         if(plib_fvals[i] < fc)
@@ -80,7 +84,7 @@ float pathlib_expandnode_starf(entity node, vector start, vector goal)
 
     pathlib_makenode(node, start, bp, goal, pathlib_gridsize);
 
-    for(i = 0; i < 3; ++i)
+    for(int i = 0; i < 3; ++i)
     {
         pathlib_makenode(node, start, plib_points2[i], goal, pathlib_gridsize);
     }
@@ -90,19 +94,19 @@ float pathlib_expandnode_starf(entity node, vector start, vector goal)
 
 float pathlib_expandnode_star(entity node, vector start, vector goal)
 {
-    vector point, where, f, r;
+    vector point;
 
-    where = node.origin;
+    vector where = node.origin;
 
-    f = PLIB_FORWARD * pathlib_gridsize;
-    r = PLIB_RIGHT   * pathlib_gridsize;
+    vector f = PLIB_FORWARD * pathlib_gridsize;
+    vector r = PLIB_RIGHT   * pathlib_gridsize;
 
     if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
-        node.pathlib_node_edgeflags = tile_check_plus2(node.origin);
+        node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
 
     if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
     {
-        dprint("Node at ", vtos(node.origin), " not expanable");
+        LOG_TRACE("Node at ", vtos(node.origin), " not expanable");
         return pathlib_open_cnt;
     }
 
@@ -169,12 +173,12 @@ float pathlib_expandnode_star(entity node, vector start, vector goal)
 
 float pathlib_expandnode_octagon(entity node, vector start, vector goal)
 {
-    vector point,where,f,r;
+    vector point;
 
-    where = node.origin;
+    vector where = node.origin;
 
-    f = PLIB_FORWARD * pathlib_gridsize;
-    r = PLIB_RIGHT   * pathlib_gridsize;
+    vector f = PLIB_FORWARD * pathlib_gridsize;
+    vector r = PLIB_RIGHT   * pathlib_gridsize;
 
     // Forward
     point = where + f;
@@ -220,9 +224,9 @@ float pathlib_expandnode_box(entity node, vector start, vector goal)
 {
     vector v;
 
-    for(v_z = node.origin_z - pathlib_gridsize; v_z <= node.origin_z + pathlib_gridsize; v_z += pathlib_gridsize)
-    for(v_y = node.origin_y - pathlib_gridsize; v_y <= node.origin_y + pathlib_gridsize; v_y += pathlib_gridsize)
-    for(v_x = node.origin_x - pathlib_gridsize; v_x <= node.origin_x + pathlib_gridsize; v_x += pathlib_gridsize)
+    for(v.z = node.origin.z - pathlib_gridsize; v.z <= node.origin.z + pathlib_gridsize; v.z += pathlib_gridsize)
+    for(v.y = node.origin.y - pathlib_gridsize; v.y <= node.origin.y + pathlib_gridsize; v.y += pathlib_gridsize)
+    for(v.x = node.origin.x - pathlib_gridsize; v.x <= node.origin.x + pathlib_gridsize; v.x += pathlib_gridsize)
     {
         //if(vlen(v - node.origin))
             pathlib_makenode(node,start,v,goal,pathlib_movecost);