From: paramat Date: Sat, 27 Jan 2018 00:52:14 +0000 (+0000) Subject: Intersects_protection(): Remove from Minetest Game X-Git-Tag: 5.0.0~121 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8f85ca57f3a50569e1cd310652dd519a8fe5cb43;p=oweals%2Fminetest_game.git Intersects_protection(): Remove from Minetest Game Add compatibility code with deprecation warning. --- diff --git a/mods/default/functions.lua b/mods/default/functions.lua index 20cf492a..d43ab7b9 100644 --- a/mods/default/functions.lua +++ b/mods/default/functions.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 -- diff --git a/mods/default/legacy.lua b/mods/default/legacy.lua index 0669914c..17e30360 100644 --- a/mods/default/legacy.lua +++ b/mods/default/legacy.lua @@ -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 diff --git a/mods/default/trees.lua b/mods/default/trees.lua index 44176d77..2934330d 100644 --- a/mods/default/trees.lua +++ b/mods/default/trees.lua @@ -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,