Browse Source

don't crash on find_nodes_in_area for big areas

main
Hendrik Langer 5 years ago
parent
commit
38974d220e
  1. 10
      mod_areas.lua

10
mod_areas.lua

@ -11,8 +11,9 @@ function creative_regions:get_areas_area_size(areas_area)
local pos1 = areas_area.pos1
local pos2 = areas_area.pos2
local x = math.abs( pos2.x - pos1.x )
local z = math.abs( pos2.z - pos1.x )
return x*z
local z = math.abs( pos2.z - pos1.z )
local y = math.abs( pos2.y - pos1.y )
return x*z*y
end
if minetest.get_modpath("areas") then
@ -23,6 +24,11 @@ if minetest.get_modpath("areas") then
local area_id = "a"..tostring(id)
creative_regions.set_region_privs(area_id, nil)
creative_regions.save_regions()
if creative_regions:get_areas_area_size(area) > 4096000 then
minetest.chat_send_player(owner, "[creative_regions] area " .. area_id .. " too big. Can't search for Protector Blocks")
minetest.log("warning", "[creative_regions] area " .. area_id .. " too big. Can't search for Protector Blocks")
return
end
local protectors_in_area = minetest.find_nodes_in_area(area.pos1, area.pos2, {"creative_regions:protector_nofly", "creative_regions:protector_arena"})
for _, pos in ipairs(protectors_in_area) do
local meta = minetest.get_meta(pos)

Loading…
Cancel
Save