1
0
Fork 0

[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.
This commit is contained in:
iliekprogrammar 2022-08-07 00:13:03 +08:00
parent 3922c5bdca
commit 221ee0fcf1
No known key found for this signature in database
GPG Key ID: 8E7B20514DBCFBFA
7 changed files with 10 additions and 1 deletions

View File

@ -337,12 +337,13 @@ local function trace_explode(pos, strength, raydirs, radius, info, direct, sourc
if not obj:is_player() then if not obj:is_player() then
return return
end end
-- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS
mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source}) mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source})
obj:add_velocity(vector.multiply(punch_dir, impact * 20)) obj:add_velocity(vector.multiply(punch_dir, impact * 20))
end) end)
else else
-- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS
mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source}) mcl_util.deal_damage(obj, damage, {type = "explosion", direct = direct, source = source})
if obj:is_player() or ent.tnt_knockback then if obj:is_player() or ent.tnt_knockback then

View File

@ -201,6 +201,7 @@ function boat.on_punch(self, puncher, time_from_last_punch, tool_capabilities, d
end end
function boat.on_step(self, dtime, moveresult) function boat.on_step(self, dtime, moveresult)
-- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS
mcl_burning.tick(self.object, dtime, self) mcl_burning.tick(self.object, dtime, self)
self._v = get_v(self.object:get_velocity()) * get_sign(self._v) self._v = get_v(self.object:get_velocity()) * get_sign(self._v)

View File

@ -3617,6 +3617,7 @@ local mob_step = function(self, dtime)
check_item_pickup(self) check_item_pickup(self)
check_aggro(self,dtime) check_aggro(self,dtime)
if not self.fire_resistant then if not self.fire_resistant then
-- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS
mcl_burning.tick(self.object, dtime, self) mcl_burning.tick(self.object, dtime, self)
end end

View File

@ -120,6 +120,8 @@ function lightning.strike(pos)
if not pos then if not pos then
return false return false
end 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) local objects = get_objects_inside_radius(pos2, 3.5)
if lightning.on_strike_functions then if lightning.on_strike_functions then
for _, func in pairs(lightning.on_strike_functions) do 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 elseif lua and lua.name == "mobs_mc:creeper" then
mcl_util.replace_mob(obj, "mobs_mc:creeper_charged") mcl_util.replace_mob(obj, "mobs_mc:creeper_charged")
else else
-- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS
mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" }) mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" })
end end
end end

View File

@ -89,6 +89,7 @@ mcl_damage.register_modifier(function(obj, damage, reason)
local thorns_damage = thorns_damage_regular + thorns_damage_irregular local thorns_damage = thorns_damage_regular + thorns_damage_irregular
if thorns_damage > 0 and reason.type ~= "thorns" and reason.source ~= obj then 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}) mcl_util.deal_damage(reason.source, thorns_damage, {type = "thorns", direct = obj})
local thorns_item = thorns_pieces[math.random(#thorns_pieces)] local thorns_item = thorns_pieces[math.random(#thorns_pieces)]

View File

@ -114,6 +114,7 @@ local function damage_particles(pos, is_critical)
end end
function ARROW_ENTITY.on_step(self, dtime) function ARROW_ENTITY.on_step(self, dtime)
-- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS
mcl_burning.tick(self.object, dtime, self) mcl_burning.tick(self.object, dtime, self)
self._time_in_air = self._time_in_air + .001 self._time_in_air = self._time_in_air + .001

View File

@ -312,6 +312,7 @@ local function damage_particles(pos, is_critical)
end end
function ARROW_ENTITY.on_step(self, dtime) function ARROW_ENTITY.on_step(self, dtime)
-- ERROR: [#2523] THIS WILL CAUSE INVALID OBJECTREFS
mcl_burning.tick(self.object, dtime, self) mcl_burning.tick(self.object, dtime, self)
self._time_in_air = self._time_in_air + .001 self._time_in_air = self._time_in_air + .001