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.
This commit is contained in:
savilli 2023-04-27 14:13:43 +02:00 committed by GitHub
parent de5ddbd4c1
commit 934fb37aef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -296,7 +296,7 @@ function creatura.find_lvm_path(self, start, goal, obj_width, obj_height, max_op
fail_safe = fail_safe + 1 fail_safe = fail_safe + 1
end end
repeat 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) table.insert(path, closedSet[current_id].pos)
current_id = closedSet[current_id].parent current_id = closedSet[current_id].parent
until current_id == start_index or #path >= fail_safe until current_id == start_index or #path >= fail_safe