Compare commits

...

1 Commits

Author SHA1 Message Date
cora ae2c60722f
Fix C stack overflow upon portal destruction
Destroying a nether portal could cause a C stack overflow for
large portals when not using luajit. This patch defers removal of
the "next batch" of portal nodes to the next globalstep via
minetest.after. This has the additional bonus of a neat visual
effect depending on server conditions.
2022-02-20 13:48:31 +01:00
1 changed files with 12 additions and 6 deletions

View File

@ -93,14 +93,20 @@ local function destroy_nether_portal(pos)
return
end
if orientation == 0 then
check_remove({x = pos.x - 1, y = pos.y, z = pos.z}, 0)
check_remove({x = pos.x + 1, y = pos.y, z = pos.z}, 0)
minetest.after(0,function()
check_remove({x = pos.x - 1, y = pos.y, z = pos.z}, 0)
check_remove({x = pos.x + 1, y = pos.y, z = pos.z}, 0)
end)
else
check_remove({x = pos.x, y = pos.y, z = pos.z - 1}, 1)
check_remove({x = pos.x, y = pos.y, z = pos.z + 1}, 1)
minetest.after(0,function()
check_remove({x = pos.x, y = pos.y, z = pos.z - 1}, 1)
check_remove({x = pos.x, y = pos.y, z = pos.z + 1}, 1)
end)
end
check_remove({x = pos.x, y = pos.y - 1, z = pos.z})
check_remove({x = pos.x, y = pos.y + 1, z = pos.z})
minetest.after(0,function()
check_remove({x = pos.x, y = pos.y - 1, z = pos.z})
check_remove({x = pos.x, y = pos.y + 1, z = pos.z})
end)
end
minetest.register_node("mcl_portals:portal", {