From 897538d3fa15dd1b974ab80600e1a09efe869caf Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Wed, 19 Jun 2019 14:41:16 +0200 Subject: [PATCH] limit cpu time of the quarry --- technic/machines/HV/quarry.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/technic/machines/HV/quarry.lua b/technic/machines/HV/quarry.lua index 6db33a2..9ead60a 100644 --- a/technic/machines/HV/quarry.lua +++ b/technic/machines/HV/quarry.lua @@ -178,7 +178,17 @@ local function quarry_run(pos, node) vector.multiply(qdir, -radius)) local owner = meta:get_string("owner") local nd = meta:get_int("dug") + + local t0 = minetest.get_us_time() + while nd < diameter*diameter * (quarry_dig_above_nodes+1+quarry_max_depth) do + + local us_used = minetest.get_us_time() - t0 + if us_used > 50000 then + -- abort if this quarry takes too much time + break + end + local ry = math.floor(nd / (diameter*diameter)) local ndl = nd % (diameter*diameter) if ry % 2 == 1 then