From 7daf1177445c6faf7f181939cb680fb3b1ea6ccb Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 9 Apr 2016 00:01:38 +0200 Subject: [PATCH] Add findPathFreeMemory() Lua function --- Aquaria/PathFinding.cpp | 5 +++++ Aquaria/PathFinding.h | 1 + Aquaria/ScriptInterface.cpp | 8 ++++++++ 3 files changed, 14 insertions(+) diff --git a/Aquaria/PathFinding.cpp b/Aquaria/PathFinding.cpp index 03fbfd4..d1eee58 100644 --- a/Aquaria/PathFinding.cpp +++ b/Aquaria/PathFinding.cpp @@ -239,6 +239,11 @@ bool PathFinding::finishFindPath(PathFinding::State *state, VectorPath& path, un return true; } +void PathFinding::purgeFindPath(PathFinding::State *state) +{ + state->searcher.freeMemory(); +} + void PathFinding::getStats(PathFinding::State *state, unsigned& stepsDone, unsigned& nodesExpanded) { stepsDone = (unsigned)state->searcher.getStepsDone(); diff --git a/Aquaria/PathFinding.h b/Aquaria/PathFinding.h index 1193afb..f152e6c 100644 --- a/Aquaria/PathFinding.h +++ b/Aquaria/PathFinding.h @@ -47,6 +47,7 @@ namespace PathFinding bool updateFindPath(State *state, int limit); bool finishFindPath(State *state, VectorPath& path, unsigned step = 0); void getStats(State *state, unsigned& stepsDone, unsigned& nodesExpanded); + void purgeFindPath(PathFinding::State *state); }; #endif diff --git a/Aquaria/ScriptInterface.cpp b/Aquaria/ScriptInterface.cpp index 12811ec..994f5af 100644 --- a/Aquaria/ScriptInterface.cpp +++ b/Aquaria/ScriptInterface.cpp @@ -9034,6 +9034,13 @@ luaFunc(findPathGetStats) return 2; } +luaFunc(findPathFreeMemory) +{ + PathFinding::State *state = *(PathFinding::State**)luaL_checkudata(L, 1, "pathfinder"); + PathFinding::purgeFindPath(state); + luaReturnNil(); +} + luaFunc(castLine) { Vector v(lua_tonumber(L, 1), lua_tonumber(L, 2)); @@ -10100,6 +10107,7 @@ static const struct { luaRegister(findPathUpdate), luaRegister(findPathFinish), luaRegister(findPathGetStats), + luaRegister(findPathFreeMemory), luaRegister(castLine), luaRegister(getUserInputString), luaRegister(getMaxCameraValues),