mirror of
https://github.com/ineedbots/iw4_bot_warfare.git
synced 2025-04-20 13:15:44 +00:00
Added low memory mode
This commit is contained in:
parent
7a0dc3b7f9
commit
e14196e3fc
@ -23,6 +23,11 @@ init()
|
|||||||
if (!getDvarInt("bots_main"))
|
if (!getDvarInt("bots_main"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if(getDvar("bots_main_lowmem") == "")
|
||||||
|
setDvar("bots_main_lowmem", false);//lower memory usage mode, more cpu
|
||||||
|
|
||||||
|
level.bots_lowmem = getDvarInt("bots_main_lowmem");
|
||||||
|
|
||||||
thread load_waypoints();
|
thread load_waypoints();
|
||||||
thread hook_callbacks();
|
thread hook_callbacks();
|
||||||
|
|
||||||
|
@ -1116,7 +1116,10 @@ load_waypoints()
|
|||||||
level.waypoints[i].childCount = level.waypoints[i].children.size;
|
level.waypoints[i].childCount = level.waypoints[i].children.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
level.waypointsKDTree = WaypointsToKDTree();
|
if (!level.bots_lowmem)
|
||||||
|
{
|
||||||
|
level.waypointsKDTree = WaypointsToKDTree();
|
||||||
|
}
|
||||||
|
|
||||||
level.waypointsCamp = [];
|
level.waypointsCamp = [];
|
||||||
level.waypointsTube = [];
|
level.waypointsTube = [];
|
||||||
@ -1885,6 +1888,27 @@ GetNearestWaypointWithSight(pos)
|
|||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Will linearly search for the nearest waypoint
|
||||||
|
*/
|
||||||
|
GetNearestWaypoint(pos)
|
||||||
|
{
|
||||||
|
candidate = undefined;
|
||||||
|
dist = 2147483647;
|
||||||
|
|
||||||
|
for(i = 0; i < level.waypointCount; i++)
|
||||||
|
{
|
||||||
|
curdis = DistanceSquared(level.waypoints[i].origin, pos);
|
||||||
|
if(curdis > dist)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
dist = curdis;
|
||||||
|
candidate = level.waypoints[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Modified Pezbot astar search.
|
Modified Pezbot astar search.
|
||||||
This makes use of sets for quick look up and a heap for a priority queue instead of simple lists which require to linearly search for elements everytime.
|
This makes use of sets for quick look up and a heap for a priority queue instead of simple lists which require to linearly search for elements everytime.
|
||||||
@ -1898,7 +1922,11 @@ AStarSearch(start, goal, team, greedy_path)
|
|||||||
|
|
||||||
closed = [];//set for quick lookup
|
closed = [];//set for quick lookup
|
||||||
|
|
||||||
startwp = level.waypointsKDTree KDTreeNearest(start);//balanced kdtree, for nns
|
startwp = undefined;
|
||||||
|
if (level.bots_lowmem)
|
||||||
|
startwp = getNearestWaypoint(start);
|
||||||
|
else
|
||||||
|
startwp = level.waypointsKDTree KDTreeNearest(start);//balanced kdtree, for nns
|
||||||
if(!isDefined(startwp))
|
if(!isDefined(startwp))
|
||||||
return [];
|
return [];
|
||||||
_startwp = undefined;
|
_startwp = undefined;
|
||||||
@ -1908,7 +1936,11 @@ AStarSearch(start, goal, team, greedy_path)
|
|||||||
startwp = _startwp;
|
startwp = _startwp;
|
||||||
startwp = startwp.index;
|
startwp = startwp.index;
|
||||||
|
|
||||||
goalwp = level.waypointsKDTree KDTreeNearest(goal);
|
goalwp = undefined;
|
||||||
|
if (level.bots_lowmem)
|
||||||
|
goalwp = getNearestWaypoint(goal);
|
||||||
|
else
|
||||||
|
goalwp = level.waypointsKDTree KDTreeNearest(goal);
|
||||||
if(!isDefined(goalwp))
|
if(!isDefined(goalwp))
|
||||||
return [];
|
return [];
|
||||||
_goalwp = undefined;
|
_goalwp = undefined;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user