Get rid of recursive call in default.dig_up

This commit is contained in:
1F616EMO 2024-06-17 16:50:48 +08:00
parent 511619253f
commit 4ce5dba268
No known key found for this signature in database
GPG key ID: EF52EFA8E05859B2
2 changed files with 19 additions and 6 deletions

View file

@ -293,12 +293,25 @@ minetest.register_abm({
-- Dig upwards
--
function default.dig_up(pos, node, digger)
local in_dig_up = false
function default.dig_up(pos, node, digger, max_height)
if in_dig_up then return end -- Avoid excess calls
if digger == nil then return end
local np = {x = pos.x, y = pos.y + 1, z = pos.z}
local nn = minetest.get_node(np)
if nn.name == node.name then
minetest.node_dig(np, nn, digger)
max_height = max_height or tonumber(minetest.settings:get("mapgen_limit")) or 31007
for y = pos.y + 1, max_height do
local up_pos = { x = pos.x, y = y, z = pos.z}
local up_node = minetest.get_node(up_pos)
if up_node.name == node.name then
in_dig_up = true
if not minetest.dig_node(up_pos, digger) then
in_dig_up = false
break
end
in_dig_up = false
else
break
end
end
end

View file

@ -17,7 +17,7 @@ default.get_translator = S
-- and avoids obscure, hard to debug runtime errors.
-- This section should be updated before release and older checks can be dropped
-- when newer ones are introduced.
if ItemStack("").add_wear_by_uses == nil then
if not minetest.features.node_interaction_actor then
error("\nThis version of Minetest Game is incompatible with your engine version "..
"(which is too old). You should download a version of Minetest Game that "..
"matches the installed engine version.\n")