X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fserver%2Fpathlib%2Fpath_waypoint.qc;h=35dcce5b25030cad21e169218900308c5c1f6f55;hb=b9671f63469586007314131f3f53728795c035cd;hp=9f443b0ac7659e0d16a81af1a1a3e031132ccb81;hpb=0ab7132eba1a94b5ec19efe5a3f5f63071ed80ff;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/pathlib/path_waypoint.qc b/qcsrc/server/pathlib/path_waypoint.qc index 9f443b0ac..35dcce5b2 100644 --- a/qcsrc/server/pathlib/path_waypoint.qc +++ b/qcsrc/server/pathlib/path_waypoint.qc @@ -1,3 +1,9 @@ +#include "path_waypoint.qh" +#include "../bot/waypoints.qh" + +#include "pathlib.qh" +#include "main.qh" + var float pathlib_wpp_open(entity wp, entity child, float cost); void pathlib_wpp_close(entity wp) @@ -8,17 +14,17 @@ void pathlib_wpp_close(entity wp) wp.pathlib_list = closedlist; if(wp == best_open_node) - best_open_node = world; + best_open_node = NULL; if(wp == goal_node) - pathlib_foundgoal = TRUE; + pathlib_foundgoal = true; } float pathlib_wpp_opencb(entity wp, entity child, float cost) { if(child.pathlib_list == closedlist) - return FALSE; + return false; // FIXME! wp.wp##mincost is NOT distance. Make it distance or add a field for distance to be used here (for better speed) cost = vlen(child.origin - wp.origin); @@ -32,21 +38,21 @@ float pathlib_wpp_opencb(entity wp, entity child, float cost) if(child == goal_node) - pathlib_foundgoal = TRUE; + pathlib_foundgoal = true; ++pathlib_open_cnt; if(best_open_node.pathlib_node_f > child.pathlib_node_f) best_open_node = child; - return TRUE; + return true; } float pathlib_wpp_openncb(entity wp, entity child, float cost) { if(child.pathlib_list == closedlist) - return FALSE; + return false; // FIXME! wp.wp##mincost is NOT distance. Make it distance or add a field for distance to be used here (for better speed) cost = vlen(child.origin - wp.origin); @@ -58,14 +64,14 @@ float pathlib_wpp_openncb(entity wp, entity child, float cost) child.pathlib_node_f = child.pathlib_node_g + child.pathlib_node_h; if(child == goal_node) - pathlib_foundgoal = TRUE; + pathlib_foundgoal = true; ++pathlib_open_cnt; if(best_open_node.pathlib_node_f > child.pathlib_node_f) best_open_node = child; - return TRUE; + return true; } float pathlib_wpp_expand(entity wp) @@ -138,7 +144,7 @@ entity pathlib_waypointpath(entity wp_from, entity wp_to, float callback) pathlib_movecost_diag = vlen('1 1 0' * pathlib_movecost); if (!pathlib_wpp_waypointcallback) - callback = FALSE; + callback = false; if (callback) pathlib_wpp_open = pathlib_wpp_opencb; @@ -156,15 +162,15 @@ entity pathlib_waypointpath(entity wp_from, entity wp_to, float callback) pathlib_closed_cnt = 0; pathlib_open_cnt = 0; pathlib_searched_cnt = 0; - pathlib_foundgoal = FALSE; + pathlib_foundgoal = false; - dprint("pathlib_waypointpath init\n"); + LOG_TRACE("pathlib_waypointpath init\n"); // Initialize waypoint grid // FIXME! presisted chain for better preformance for(n = findchain(classname, "waypoint"); n; n = n.chain) { - n.pathlib_list = world; + n.pathlib_list = NULL; n.pathlib_node_g = 0; n.pathlib_node_f = 0; n.pathlib_node_h = 0; @@ -180,14 +186,14 @@ entity pathlib_waypointpath(entity wp_from, entity wp_to, float callback) start_node = wp_from; start_node.pathlib_list = closedlist; - dprint("Expanding ",ftos(pathlib_wpp_expand(start_node))," links\n"); + LOG_TRACE("Expanding ",ftos(pathlib_wpp_expand(start_node))," links\n"); if(pathlib_open_cnt <= 0) { - dprint("pathlib_waypointpath: Start waypoint not linked! aborting.\n"); - return world; + LOG_TRACE("pathlib_waypointpath: Start waypoint not linked! aborting.\n"); + return NULL; } - return world; + return NULL; } entity pathlib_waypointpath_step() @@ -197,21 +203,21 @@ entity pathlib_waypointpath_step() n = pathlib_wpp_bestopen(); if(!n) { - dprint("Cannot find best open node, abort.\n"); - return world; + LOG_TRACE("Cannot find best open node, abort.\n"); + return NULL; } pathlib_wpp_close(n); - dprint("Expanding ",ftos(pathlib_wpp_expand(n))," links\n"); + LOG_TRACE("Expanding ",ftos(pathlib_wpp_expand(n))," links\n"); if(pathlib_foundgoal) { entity start, end, open, ln; - dprint("Target found. Rebuilding and filtering path...\n"); + LOG_TRACE("Target found. Rebuilding and filtering path...\n"); buildpath_nodefilter = buildpath_nodefilter_none; - start = path_build(world, start_node.origin, world, world); - end = path_build(world, goal_node.origin, world, start); + start = path_build(NULL, start_node.origin, NULL, NULL); + end = path_build(NULL, goal_node.origin, NULL, start); ln = end; for(open = goal_node; open.path_prev != start_node; open = open.path_prev) @@ -226,20 +232,20 @@ entity pathlib_waypointpath_step() return start; } - return world; + return NULL; } -void plas_think() +void plas_think(entity this) { pathlib_waypointpath_step(); if(pathlib_foundgoal) return; - self.nextthink = time + 0.1; + this.nextthink = time + 0.1; } void pathlib_waypointpath_autostep() { entity n; n = spawn(); - n.think = plas_think; + setthink(n, plas_think); n.nextthink = time + 0.1; }