-#include "../_all.qh"
+#include "main.qh"
#include "pathlib.qh"
#include "utility.qh"
e = findchainentity(owner, start);
while(e)
{
- e.think = SUB_Remove;
+ setthink(e, SUB_Remove_self);
e.nextthink = time;
e = e.chain;
}
void dumpnode(entity n)
{
n.is_path_node = false;
- n.think = SUB_Remove;
+ setthink(n, 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;
node = spawn();
- node.think = SUB_Remove;
+ setthink(node, SUB_Remove_self);
node.nextthink = time + PATHLIB_NODEEXPIRE;
node.is_path_node = true;
node.owner = openlist;
setorigin(node, where);
node.medium = pointcontents(where);
+#if DEBUGPATHING
pathlib_showsquare(where, 1 ,15);
-
+#endif
++pathlib_made_cnt;
++pathlib_open_cnt;
return 1;
}
- where = pathlib_movenode(parent.origin, to, 0);
+ where = pathlib_movenode(parent, parent.origin, to, 0);
if (!pathlib_movenode_goodnode)
{
if(doedge)
- if (!tile_check(where))
+ if (!tile_check(parent, where))
{
LOG_TRACE("tile_check fail\n");
+#if DEBUGPATHING
pathlib_showsquare(where, 0 ,30);
+#endif
return 0;
}
{
if(node.pathlib_node_g > g)
{
- //pathlib_movenode(where,node.origin,0);
+ //pathlib_movenode(node, where,node.origin,0);
//if(pathlib_movenode_goodnode)
//{
//mark_error(node.origin + '0 0 128',30);
node.owner = closedlist;
- if(vlen(node.origin - goal) <= pathlib_gridsize)
+ if(vdist(node.origin - goal, <=, pathlib_gridsize))
{
vector goalmove;
- goalmove = pathlib_walknode(node.origin,goal,1);
+ goalmove = pathlib_walknode(node, node.origin, goal, 1);
if(pathlib_movenode_goodnode)
{
goal_node = node;
return 0;
}
-float buildpath_nodefilter_moveskip(vector n,vector c,vector p)
+float buildpath_nodefilter_moveskip(entity this, vector n,vector c,vector p)
{
- pathlib_walknode(p,n,1);
+ pathlib_walknode(this, p, n, 1);
if(pathlib_movenode_goodnode)
return 1;
{
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();
ctime = gettime(GETTIME_REALTIME) - ctime;
-#ifdef DEBUGPATHING
+#if DEBUGPATHING
pathlib_showpath2(start);
LOG_TRACE("Time used - pathfinding: ", ftos(ptime),"\n");