From 934fb37aefb1823cadda0e62d9f359af79edd08e Mon Sep 17 00:00:00 2001 From: savilli <78875209+savilli@users.noreply.github.com> Date: Thu, 27 Apr 2023 14:13:43 +0200 Subject: [PATCH] Fix crash in pathfinder We need to save `self._path_data` before any return. Otherwise old data will cause crashes, for example because `self._path_data.count` > `openSet` size. --- pathfinder.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pathfinder.lua b/pathfinder.lua index 83d5ea8..2577a96 100644 --- a/pathfinder.lua +++ b/pathfinder.lua @@ -296,7 +296,7 @@ function creatura.find_lvm_path(self, start, goal, obj_width, obj_height, max_op fail_safe = fail_safe + 1 end repeat - if not closedSet[current_id] then return end + if not closedSet[current_id] then self._path_data = {} return end table.insert(path, closedSet[current_id].pos) current_id = closedSet[current_id].parent until current_id == start_index or #path >= fail_safe