Skip to content
Permalink
Browse files

Intersects_protection(): Remove from Minetest Game

Add compatibility code with deprecation warning.
  • Loading branch information
paramat committed Feb 3, 2018
1 parent 496a1a2 commit 8f85ca57f3a50569e1cd310652dd519a8fe5cb43
Showing with 8 additions and 41 deletions.
  1. +0 −40 mods/default/functions.lua
  2. +7 −0 mods/default/legacy.lua
  3. +1 −1 mods/default/trees.lua
@@ -497,46 +497,6 @@ minetest.register_abm({
})


--
-- Checks if specified volume intersects a protected volume
--

function default.intersects_protection(minp, maxp, player_name, interval)
-- 'interval' is the largest allowed interval for the 3D lattice of checks

-- Compute the optimal float step 'd' for each axis so that all corners and
-- borders are checked. 'd' will be smaller or equal to 'interval'.
-- Subtracting 1e-4 ensures that the max co-ordinate will be reached by the
-- for loop (which might otherwise not be the case due to rounding errors).
local d = {}
for _, c in pairs({"x", "y", "z"}) do
if maxp[c] > minp[c] then
d[c] = (maxp[c] - minp[c]) / math.ceil((maxp[c] - minp[c]) / interval) - 1e-4
elseif maxp[c] == minp[c] then
d[c] = 1 -- Any value larger than 0 to avoid division by zero
else -- maxp[c] < minp[c], print error and treat as protection intersected
minetest.log("error", "maxp < minp in 'default.intersects_protection()'")
return true
end
end

for zf = minp.z, maxp.z, d.z do
local z = math.floor(zf + 0.5)
for yf = minp.y, maxp.y, d.y do
local y = math.floor(yf + 0.5)
for xf = minp.x, maxp.x, d.x do
local x = math.floor(xf + 0.5)
if minetest.is_protected({x = x, y = y, z = z}, player_name) then
return true
end
end
end
end

return false
end


--
-- Coral death near air
--
@@ -37,3 +37,10 @@ end

-- Chests
default.register_chest = default.chest.register_chest

-- Check for a volume intersecting protection
function default.intersects_protection(minp, maxp, player_name, interval)
minetest.log("warning", "default.intersects_protection() is " ..
"deprecated, use minetest.intersects_protection() instead.")
minetest.intersects_protection(minp, maxp, player_name, interval)
end
@@ -490,7 +490,7 @@ function default.sapling_on_place(itemstack, placer, pointed_thing,
return itemstack
end
-- Check tree volume for protection
if default.intersects_protection(
if minetest.intersects_protection(
vector.add(pos, minp_relative),
vector.add(pos, maxp_relative),
player_name,

0 comments on commit 8f85ca5

Please sign in to comment.
You can’t perform that action at this time.