From 4c8d42bf7b9b005a1f9e36cc5964b5d416e47b03 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 26 May 2024 14:50:11 +0200 Subject: [PATCH] Refuse too large areas in worldedit.keep_loaded() fixes #234 --- worldedit/common.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/worldedit/common.lua b/worldedit/common.lua index 2617985..4ac6ade 100644 --- a/worldedit/common.lua +++ b/worldedit/common.lua @@ -45,10 +45,15 @@ function worldedit.get_axis_others(axis) end +-- Create a vmanip and read the area from map, this causes all +-- MapBlocks to be loaded into memory synchronously. +-- This doesn't actually *keep* them loaded, unlike the name implies. function worldedit.keep_loaded(pos1, pos2) - -- Create a vmanip and read the area from map, this - -- causes all MapBlocks to be loaded into memory synchronously. - -- This doesn't actually *keep* them loaded, unlike the name implies. + -- 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 -- same effect but without unnecessary data copying minetest.load_area(pos1, pos2)