From bc80a079bc8bc37811e5852be3cc0ac0dfa2234d Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Fri, 27 Feb 2015 12:29:43 -0500 Subject: [PATCH] Play out the rest of the mapblock log at standard shutdown This prevents unpopulated map areas being left over after a restart. Adds a fairly large shutdown penalty to the engine only if the mapgen is actively generating at the time of shutdown. If the mapgen is more or less idle, no extra time is added. --- plants_lib/init.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plants_lib/init.lua b/plants_lib/init.lua index edb28e1..d13856a 100644 --- a/plants_lib/init.lua +++ b/plants_lib/init.lua @@ -434,6 +434,27 @@ minetest.register_globalstep(function(dtime) plantslib:generate_block_no_aircheck(dtime) end) +-- Play out the entire log all at once on shutdown +-- to prevent unpopulated map areas + +minetest.register_on_shutdown(function() + print("[plants_lib] Stand by, playing out the rest of the aircheck mapblock log") + print("(there are "..#plantslib.blocklist_aircheck.." entries)...") + while true do + plantslib:generate_block_with_air_checking(0.1) + if #plantslib.blocklist_aircheck == 0 then return end + end +end) + +minetest.register_on_shutdown(function() + print("[plants_lib] Stand by, playing out the rest of the no-aircheck mapblock log") + print("(there are "..#plantslib.blocklist_aircheck.." entries)...") + while true do + plantslib:generate_block_no_aircheck(0.1) + if #plantslib.blocklist_no_aircheck == 0 then return end + end +end) + -- The spawning ABM function plantslib:spawn_on_surfaces(sd,sp,sr,sc,ss,sa)