From 221ee0fcf1da898fffbfaeda1fddb1c22491a3da Mon Sep 17 00:00:00 2001 From: iliekprogrammar Date: Sun, 7 Aug 2022 00:13:03 +0800 Subject: [PATCH] [5.6] mark places with unsafe set_hp entity handling There might be other places i might be missing, but these are the obvious ones. leftover entity handling i did not mark: * everything that involves a apply()-like algorithm (e.g. callbacks) over the same list of objects. * in mcl_damage, it's not known whether mcl_damage.from_mt() would involve entity handling or just player handling. --- mods/CORE/mcl_explosions/init.lua | 3 ++- mods/ENTITIES/mcl_boats/init.lua | 1 + mods/ENTITIES/mcl_mobs/api.lua | 1 + mods/ENVIRONMENT/lightning/init.lua | 3 +++ mods/ITEMS/mcl_armor/damage.lua | 1 + mods/ITEMS/mcl_bows/arrow.lua | 1 + mods/ITEMS/mcl_bows/rocket.lua | 1 + 7 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mods/CORE/mcl_explosions/init.lua b/mods/CORE/mcl_explosions/init.lua index 0132d1669..92453a9d5 100644 --- a/mods/CORE/mcl_explosions/init.lua +++ b/mods/CORE/mcl_explosions/init.lua @@ -337,12 +337,13 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc if not obj:is_player() then return end - + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source}) obj:add_velocity(vector.multiply(punch_dir, impact * 20)) end) else + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source}) if obj:is_player() or ent.tnt_knockback then diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 087cd7eae..cd8002b22 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -201,6 +201,7 @@ function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d end function boat.on_step(self, dtime, moveresult) + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_burning.tick(self.object, dtime, self) self._v = get_v(self.object:get_velocity()) * get_sign(self._v) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index 8945c6e20..d183d55c7 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -3617,6 +3617,7 @@ local mob_step = function(self, dtime) check_item_pickup(self) check_aggro(self,dtime) if not self.fire_resistant then + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_burning.tick(self.object, dtime, self) end diff --git a/mods/ENVIRONMENT/lightning/init.lua b/mods/ENVIRONMENT/lightning/init.lua index 14d8f5176..48eefce4e 100644 --- a/mods/ENVIRONMENT/lightning/init.lua +++ b/mods/ENVIRONMENT/lightning/init.lua @@ -120,6 +120,8 @@ function lightning.strike(pos) if not pos then return false end + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS + -- mcl_util.deal_damage inside one of on_strike_functions local objects = get_objects_inside_radius(pos2, 3.5) if lightning.on_strike_functions then for _, func in pairs(lightning.on_strike_functions) do @@ -174,6 +176,7 @@ lightning.register_on_strike(function(pos, pos2, objects) elseif lua and lua.name == "mobs_mc:creeper" then mcl_util.replace_mob(obj, "mobs_mc:creeper_charged") else + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" }) end end diff --git a/mods/ITEMS/mcl_armor/damage.lua b/mods/ITEMS/mcl_armor/damage.lua index ed616397d..e76f8034b 100644 --- a/mods/ITEMS/mcl_armor/damage.lua +++ b/mods/ITEMS/mcl_armor/damage.lua @@ -89,6 +89,7 @@ mcl_damage.register_modifier(function(obj, damage, reason) local thorns_damage = thorns_damage_regular + thorns_damage_irregular if thorns_damage > 0 and reason.type ~= "thorns" and reason.source ~= obj then + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_util.deal_damage(reason.source, thorns_damage, {type = "thorns", direct = obj}) local thorns_item = thorns_pieces[math.random(#thorns_pieces)] diff --git a/mods/ITEMS/mcl_bows/arrow.lua b/mods/ITEMS/mcl_bows/arrow.lua index a03b875cb..10b7f6421 100644 --- a/mods/ITEMS/mcl_bows/arrow.lua +++ b/mods/ITEMS/mcl_bows/arrow.lua @@ -114,6 +114,7 @@ local function damage_particles(pos, is_critical) end function ARROW_ENTITY.on_step(self, dtime) + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_burning.tick(self.object, dtime, self) self._time_in_air = self._time_in_air + .001 diff --git a/mods/ITEMS/mcl_bows/rocket.lua b/mods/ITEMS/mcl_bows/rocket.lua index d25c52647..e08db5323 100644 --- a/mods/ITEMS/mcl_bows/rocket.lua +++ b/mods/ITEMS/mcl_bows/rocket.lua @@ -312,6 +312,7 @@ local function damage_particles(pos, is_critical) end function ARROW_ENTITY.on_step(self, dtime) + -- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS mcl_burning.tick(self.object, dtime, self) self._time_in_air = self._time_in_air + .001