mirror of
https://github.com/minetest/minetest_game.git
synced 2024-12-23 07:10:19 +01:00
Intersects_protection(): Remove from Minetest Game
Add compatibility code with deprecation warning.
This commit is contained in:
parent
496a1a24d2
commit
8f85ca57f3
@ -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
|
-- Coral death near air
|
||||||
--
|
--
|
||||||
|
@ -37,3 +37,10 @@ end
|
|||||||
|
|
||||||
-- Chests
|
-- Chests
|
||||||
default.register_chest = default.chest.register_chest
|
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
|
return itemstack
|
||||||
end
|
end
|
||||||
-- Check tree volume for protection
|
-- Check tree volume for protection
|
||||||
if default.intersects_protection(
|
if minetest.intersects_protection(
|
||||||
vector.add(pos, minp_relative),
|
vector.add(pos, minp_relative),
|
||||||
vector.add(pos, maxp_relative),
|
vector.add(pos, maxp_relative),
|
||||||
player_name,
|
player_name,
|
||||||
|
Loading…
Reference in New Issue
Block a user