From ae7cfdff698a73fcaeca6749515434dfa3f3fa3f Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Sun, 12 Mar 2023 23:45:41 +0000 Subject: [PATCH] Ensure conditional doesn't mask bug crash issue --- mods/ENTITIES/mcl_mobs/physics.lua | 40 ++++++++++++++++-------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 73ed94758..b6149d2a9 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -625,27 +625,31 @@ function mob_class:do_env_damage() local node = minetest.get_node(pos) if node then if node.name ~= "ignore" then - local sunlight = minetest.get_natural_light(pos, self.time_of_day) - - if self.light_damage ~= 0 and (sunlight or 0) > 12 then - if self:deal_light_damage(pos, self.light_damage) then - return true - end - end - local _, dim = mcl_worlds.y_to_layer(pos.y) - if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then - if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then - if self.ignited_by_sunlight then - mcl_burning.set_on_fire(self.object, 10) - else - self:deal_light_damage(pos, self.sunlight_damage) - return true - end - end - end + -- put below code in this block if we can prove that unloaded maps are causing crash. + -- it should warn then error else minetest.log("warning", "Pos is ignored: " .. dump(pos)) end + + local sunlight = minetest.get_natural_light(pos, self.time_of_day) + + if self.light_damage ~= 0 and (sunlight or 0) > 12 then + if self:deal_light_damage(pos, self.light_damage) then + return true + end + end + local _, dim = mcl_worlds.y_to_layer(pos.y) + if (self.sunlight_damage ~= 0 or self.ignited_by_sunlight) and (sunlight or 0) >= minetest.LIGHT_MAX and dim == "overworld" then + if self.armor_list and not self.armor_list.helmet or not self.armor_list or self.armor_list and self.armor_list.helmet and self.armor_list.helmet == "" then + if self.ignited_by_sunlight then + mcl_burning.set_on_fire(self.object, 10) + else + self:deal_light_damage(pos, self.sunlight_damage) + return true + end + end + end + end local y_level = self.collisionbox[2]