1
0
mirror of https://github.com/mt-mods/plantlife_modpack.git synced 2024-12-27 02:50:19 +01:00

read-out/play back more log entries per globalstep

if there is time to do so (up to a max of 0.2 seconds' worth)
This commit is contained in:
Vanessa Ezekowitz 2015-02-28 00:29:26 -05:00
parent bc80a079bc
commit 93a439638e

View File

@ -325,8 +325,7 @@ end
-- Primary mapgen spawner, for mods that can work with air checking enabled on -- Primary mapgen spawner, for mods that can work with air checking enabled on
-- a surface during the initial map read stage. -- a surface during the initial map read stage.
function plantslib:generate_block_with_air_checking(dtime) function plantslib:generate_block_with_air_checking()
if dtime > 0.2 then return end -- don't attempt to populate if lag is too high
if #plantslib.blocklist_aircheck > 0 then if #plantslib.blocklist_aircheck > 0 then
local minp = plantslib.blocklist_aircheck[1][1] local minp = plantslib.blocklist_aircheck[1][1]
@ -380,8 +379,7 @@ end
-- Secondary mapgen spawner, for mods that require disabling of -- Secondary mapgen spawner, for mods that require disabling of
-- checking for air during the initial map read stage. -- checking for air during the initial map read stage.
function plantslib:generate_block_no_aircheck(dtime) function plantslib:generate_block_no_aircheck()
if dtime > 0.2 then return end
if #plantslib.blocklist_no_aircheck > 0 then if #plantslib.blocklist_no_aircheck > 0 then
local minp = plantslib.blocklist_no_aircheck[1][1] local minp = plantslib.blocklist_no_aircheck[1][1]
@ -427,11 +425,19 @@ end)
-- "Play" them back, populating them with new stuff in the process -- "Play" them back, populating them with new stuff in the process
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
plantslib:generate_block_with_air_checking(dtime) if dtime < 0.2 then -- don't attempt to populate if lag is already too high
end) plantslib.globalstep_start_time = minetest.get_us_time()
plantslib.globalstep_runtime = 0
minetest.register_globalstep(function(dtime) while plantslib.globalstep_runtime < 200000 do -- 0.2 seconds, in uS.
plantslib:generate_block_no_aircheck(dtime) if #plantslib.blocklist_aircheck > 0 then
plantslib:generate_block_with_air_checking()
end
if #plantslib.blocklist_no_aircheck > 0 then
plantslib:generate_block_no_aircheck()
end
plantslib.globalstep_runtime = minetest.get_us_time() - plantslib.globalstep_start_time
end
end
end) end)
-- Play out the entire log all at once on shutdown -- Play out the entire log all at once on shutdown