Skip to content

Commit

Permalink
Prevent punching with invalid userdata
Browse files Browse the repository at this point in the history
  • Loading branch information
S-S-X committed Feb 16, 2020
1 parent a691afb commit 5e7ee1c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ local damage_def = {
damage_groups = {},
}
digtron.damage_creatures = function(player, source_pos, target_pos, amount, items_dropped)
if type(player) ~= 'userdata' then
return
end
local objects = minetest.env:get_objects_inside_radius(target_pos, 1.0)
if objects ~= nil then
damage_def.damage_groups.fleshy = amount
Expand Down Expand Up @@ -433,4 +436,4 @@ digtron.show_offset_markers = function(pos, offset, period)
local entity = safe_add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker")
if entity ~= nil then entity:setyaw(1.5708) end
end
end
end

0 comments on commit 5e7ee1c

Please sign in to comment.