forked from VoxeLibre/VoxeLibre
[5.6][lightning] fix unsafe entitiy handling
this does not excuse all on_strike callbacks to allow oversights. it must also track entity removal.
This commit is contained in:
parent
221ee0fcf1
commit
bce4d29737
|
@ -120,11 +120,10 @@ 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
|
||||
-- allow on_strike callbacks to destroy entities by re-obtaining objects for each callback
|
||||
local objects = get_objects_inside_radius(pos2, 3.5)
|
||||
func(pos, pos2, objects)
|
||||
end
|
||||
end
|
||||
|
@ -176,7 +175,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
|
||||
-- WARNING: unsafe entity handling. object may be removed immediately
|
||||
mcl_util.deal_damage(obj, 5, { type = "lightning_bolt" })
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue