]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/pathlib/main.qc
Merge branch 'master' into terencehill/translate_colors_2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / pathlib / main.qc
index 39847f635d220661cf60c9caa56f57f87b06169f..f2534805764968c5e2ba2ba215a9f2372274fd56 100644 (file)
@@ -1,4 +1,3 @@
-#include "../_all.qh"
 
 #include "pathlib.qh"
 #include "utility.qh"
@@ -11,7 +10,7 @@ void pathlib_deletepath(entity start)
     e = findchainentity(owner, start);
     while(e)
     {
-        e.think = SUB_Remove;
+        e.think = SUB_Remove_self;
         e.nextthink = time;
         e = e.chain;
     }
@@ -23,10 +22,17 @@ const float PATHLIB_NODEEXPIRE = 20;
 void dumpnode(entity n)
 {
     n.is_path_node = false;
-    n.think        = SUB_Remove;
+    n.think        = SUB_Remove_self;
     n.nextthink    = time;
 }
 
+#if DEBUGPATHING
+void pathlib_showpath(entity start);
+void pathlib_showpath2(entity path);
+void pathlib_showsquare(vector where,float goodsquare,float _lifetime);
+#endif
+
+
 entity pathlib_mknode(vector where,entity parent)
 {
     entity node;
@@ -42,7 +48,7 @@ entity pathlib_mknode(vector where,entity parent)
 
     node = spawn();
 
-    node.think        = SUB_Remove;
+    node.think        = SUB_Remove_self;
     node.nextthink    = time + PATHLIB_NODEEXPIRE;
     node.is_path_node = true;
     node.owner        = openlist;
@@ -53,8 +59,9 @@ entity pathlib_mknode(vector where,entity parent)
 
     setorigin(node, where);
     node.medium = pointcontents(where);
+#if DEBUGPATHING
     pathlib_showsquare(where, 1 ,15);
-
+#endif
     ++pathlib_made_cnt;
     ++pathlib_open_cnt;
 
@@ -150,7 +157,9 @@ float pathlib_makenode_adaptive(entity parent,vector start, vector to, vector go
         if (!tile_check(where))
         {
             LOG_TRACE("tile_check fail\n");
+#if DEBUGPATHING
             pathlib_showsquare(where, 0 ,30);
+#endif
             return 0;
         }
 
@@ -370,7 +379,7 @@ entity path_build(entity next, vector where, entity prev, entity start)
 }
 
 entity pathlib_astar(vector from,vector to)
-{
+{SELFPARAM();
     entity path, start, end, open, n, ln;
     float ptime, ftime, ctime;
 
@@ -464,9 +473,8 @@ entity pathlib_astar(vector from,vector to)
     {
         LOG_TRACE("AStar: Goal found on first node!\n");
 
-        open           = spawn();
+        open           = new(path_end);
         open.owner     = open;
-        open.classname = "path_end";
         setorigin(open,path.origin);
 
         pathlib_cleanup();
@@ -539,7 +547,7 @@ entity pathlib_astar(vector from,vector to)
             ctime = gettime(GETTIME_REALTIME) - ctime;
 
 
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
             pathlib_showpath2(start);
 
             LOG_TRACE("Time used -      pathfinding: ", ftos(ptime),"\n");