From ef093d0c003d6e9089253991f9259b1113d99b9f Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 4 Jun 2022 16:33:18 +0200 Subject: [PATCH] Be more careful with possibly expired objects --- mods/ENTITIES/mcl_burning/api.lua | 1 + mods/ITEMS/mcl_bows/rocket.lua | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 885875aca2..1d07e96f04 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -134,6 +134,7 @@ function mcl_burning.set_on_fire(obj, burn_time) end function mcl_burning.extinguish(obj) + if not obj:get_pos() then return end if mcl_burning.is_burning(obj) then local storage = mcl_burning.get_storage(obj) if obj:is_player() then diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index 9eb8ab8c4f..b8ad2c1f00 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -19,15 +19,16 @@ local function dir_to_pitch(dir) end local function damage_explosion(self, damagemulitplier) - mcl_explosions.explode(self.object:get_pos(), 3, {}) - local objects = minetest.get_objects_inside_radius(self.object:get_pos(), 8) + local p = self.object:get_pos() + mcl_explosions.explode(p, 3, {}) + local objects = minetest.get_objects_inside_radius(p, 8) for _,obj in pairs(objects) do if obj:is_player() then - mcl_util.deal_damage(obj, damagemulitplier - vector.distance(self.object:get_pos(), obj:get_pos()), {type = "explosion"}) + mcl_util.deal_damage(obj, damagemulitplier - vector.distance(p, obj:get_pos()), {type = "explosion"}) elseif obj:get_luaentity().is_mob then obj:punch(self.object, 1.0, { full_punch_interval=1.0, - damage_groups={fleshy=damagemulitplier - vector.distance(self.object:get_pos(), obj:get_pos())}, + damage_groups={fleshy=damagemulitplier - vector.distance(p, obj:get_pos())}, }, self.object:get_velocity()) end end