1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-11-16 15:40:16 +01:00

Refuse too large areas in worldedit.keep_loaded()

fixes #234
This commit is contained in:
sfan5 2024-05-26 14:50:11 +02:00
parent 5a00c07c68
commit 4c8d42bf7b

View File

@ -45,10 +45,15 @@ function worldedit.get_axis_others(axis)
end end
function worldedit.keep_loaded(pos1, pos2) -- Create a vmanip and read the area from map, this causes all
-- Create a vmanip and read the area from map, this -- MapBlocks to be loaded into memory synchronously.
-- causes all MapBlocks to be loaded into memory synchronously.
-- This doesn't actually *keep* them loaded, unlike the name implies. -- This doesn't actually *keep* them loaded, unlike the name implies.
function worldedit.keep_loaded(pos1, pos2)
-- rough estimate, a MapNode is 4 bytes in the engine
if worldedit.volume(pos1, pos2) > 268400000 then
print("[WorldEdit] Requested to load an area bigger than 1GB, refusing. The subsequent operation may fail.")
return
end
if minetest.load_area then if minetest.load_area then
-- same effect but without unnecessary data copying -- same effect but without unnecessary data copying
minetest.load_area(pos1, pos2) minetest.load_area(pos1, pos2)