mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-12-24 17:09:32 +01:00
fix two crashes in pathfinding
This commit is contained in:
parent
98231f15ae
commit
4ac41a793e
1 changed files with 2 additions and 2 deletions
|
@ -2390,7 +2390,7 @@ local do_states = function(self, dtime)
|
||||||
elseif self.state == "gowp" then
|
elseif self.state == "gowp" then
|
||||||
local p = self.object:get_pos()
|
local p = self.object:get_pos()
|
||||||
if not p or not self._target then return end
|
if not p or not self._target then return end
|
||||||
if vector.distance(p,self._target) < 2 or #self.waypoints == 0 then
|
if vector.distance(p,self._target) < 2 or ( self.waypoints and #self.waypoints == 0 ) then
|
||||||
self.waypoints = nil
|
self.waypoints = nil
|
||||||
self._target = nil
|
self._target = nil
|
||||||
self.current_target = nil
|
self.current_target = nil
|
||||||
|
@ -2398,7 +2398,7 @@ local do_states = function(self, dtime)
|
||||||
if self.callback_arrived then return self.callback_arrived(self) end
|
if self.callback_arrived then return self.callback_arrived(self) end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
if not self.current_target or vector.distance(p,self.current_target) < 1.5 then
|
if self.waypoints and ( not self.current_target or vector.distance(p,self.current_target) < 1.5 ) then
|
||||||
self.current_target = table.remove(self.waypoints, 1)
|
self.current_target = table.remove(self.waypoints, 1)
|
||||||
--minetest.log("nextwp:".. tostring(self.current_target) )
|
--minetest.log("nextwp:".. tostring(self.current_target) )
|
||||||
elseif self.current_target then
|
elseif self.current_target then
|
||||||
|
|
Loading…
Reference in a new issue