0
0
Fork 0

Fix undefined luaentity crash.

* Add nil check to get_luaentity() access.
* Cache get_luaentity() call in local var.
This commit is contained in:
kabou 2022-03-20 18:11:30 +01:00 committed by Gitea
parent 3dd4eec4e8
commit 46ee5aaa59
2 changed files with 4 additions and 4 deletions

View File

@ -222,8 +222,8 @@ local collision = function(self)
for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
if object:is_player()
or (object:get_luaentity()._cmi_is_mob == true and object ~= self.object) then
local ent = object:get_luaentity()
if object:is_player() or (ent and ent._cmi_is_mob and object ~= self.object) then
local pos2 = object:get_pos()
local vec = {x = pos.x - pos2.x, z = pos.z - pos2.z}

View File

@ -35,8 +35,8 @@ local function player_collision(player)
for _,object in pairs(minetest.get_objects_inside_radius(pos, width)) do
if object and (object:is_player()
or (object:get_luaentity()._cmi_is_mob == true and object ~= player)) then
local ent = object:get_luaentity()
if (object:is_player() or (ent and ent._cmi_is_mob and object ~= player)) then
local pos2 = object:get_pos()
local vec = {x = pos.x - pos2.x, z = pos.z - pos2.z}