update biome_lib

master
Vanessa Dannenberg 2021-04-06 16:20:18 -04:00
parent 802bf612b8
commit 22d8553f69
4 changed files with 57 additions and 20 deletions

View File

@ -424,7 +424,24 @@ end
-- Primary log read-out/mapgen spawner
function biome_lib.generate_block()
local function confirm_block_surroundings(p)
local n=minetest.get_node_or_nil(p)
if not n or n.name == "ignore" then return false end
for x = -32,32,64 do -- step of 64 causes it to only check the 8 corner blocks
for y = -32,32,64 do
for z = -32,32,64 do
local n=minetest.get_node_or_nil({x=p.x + x, y=p.y + y, z=p.z + z})
if not n or n.name == "ignore" then return false end
end
end
end
return true
end
biome_lib.block_recheck_list = {}
function biome_lib.generate_block(shutting_down)
if not biome_lib.block_log[1] then return end -- the block log is empty
local minp = biome_lib.block_log[1][1]
@ -434,14 +451,23 @@ function biome_lib.generate_block()
if not biome_lib.pos_hash then -- we need to read the maplock and get the surfaces list
biome_lib.pos_hash = {}
biome_lib.pos_hash.surface_node_list = airflag
and minetest.find_nodes_in_area_under_air(minp, maxp, biome_lib.surfaceslist_aircheck)
or minetest.find_nodes_in_area(minp, maxp, biome_lib.surfaceslist_no_aircheck)
biome_lib.pos_hash.action_index = 1
if #biome_lib.pos_hash.surface_node_list > 0 then
biome_lib:dbg("Mapblock at "..minetest.pos_to_string(minp)..
" has "..#biome_lib.pos_hash.surface_node_list..
" surface nodes to work on (airflag="..dump(airflag)..")")
if not confirm_block_surroundings(minp) and not shutting_down then -- if any neighbors appear not to be loaded, move this block to the end of the queue
biome_lib.block_recheck_list[#biome_lib.block_recheck_list + 1] = table.copy(biome_lib.block_log[1])
table.remove(biome_lib.block_log, 1)
biome_lib.pos_hash = nil
biome_lib:dbg("Mapblock at "..minetest.pos_to_string(minp)..
" had a neighbor not fully emerged, moved it to the \"check-later\" list.")
return
else
biome_lib.pos_hash.surface_node_list = airflag
and minetest.find_nodes_in_area_under_air(minp, maxp, biome_lib.surfaceslist_aircheck)
or minetest.find_nodes_in_area(minp, maxp, biome_lib.surfaceslist_no_aircheck)
biome_lib.pos_hash.action_index = 1
if #biome_lib.pos_hash.surface_node_list > 0 then
biome_lib:dbg("Mapblock at "..minetest.pos_to_string(minp)..
" has "..#biome_lib.pos_hash.surface_node_list..
" surface nodes to work on (airflag="..dump(airflag)..")")
end
end
elseif not (airflag and biome_lib.actionslist_aircheck[biome_lib.pos_hash.action_index])
and not (not airflag and biome_lib.actionslist_no_aircheck[biome_lib.pos_hash.action_index]) then
@ -481,17 +507,15 @@ end
-- "Play" them back, populating them with new stuff in the process
biome_lib.dtime_limit = tonumber(minetest.settings:get("biome_lib_dtime_limit")) or 0.5
local rr = tonumber(minetest.settings:get("biome_lib_queue_run_ratio")) or -100
biome_lib.queue_run_ratio = 100 - rr
biome_lib.entries_per_step = math.max(-rr, 1)
minetest.register_globalstep(function(dtime)
if math.random(100) > biome_lib.queue_run_ratio
or dtime > biome_lib.dtime_limit then
return
end
if not biome_lib.block_log[1] then return end -- the block log is empty
if math.random(100) > biome_lib.queue_run_ratio then return end
for s = 1, biome_lib.entries_per_step do
biome_lib.generate_block()
end
@ -501,14 +525,21 @@ end)
-- to prevent unpopulated map areas
minetest.register_on_shutdown(function()
if #biome_lib.block_log == 0 then
if #biome_lib.block_log + #biome_lib.block_recheck_list == 0 then
return
end
print("[biome_lib] Stand by, playing out the rest of the mapblock log")
print("(there are "..#biome_lib.block_log.." entries)...")
print("(there are "..(#biome_lib.block_log + #biome_lib.block_recheck_list).." entries)...")
while #biome_lib.block_log > 0 do
biome_lib.generate_block()
biome_lib.generate_block(true)
end
if #biome_lib.block_recheck_list > 0 then
biome_lib.block_log = table.copy(biome_lib.block_recheck_list)
while #biome_lib.block_log > 0 do
biome_lib.generate_block(true)
end
end
end)
@ -707,7 +738,7 @@ if DEBUG then
function biome_lib.show_pending_block_count()
if biome_lib.last_count ~= #biome_lib.block_log then
biome_lib:dbg("Pending block count: "..#biome_lib.block_log)
biome_lib:dbg("Pending block count: "..(#biome_lib.block_log + #biome_lib.block_recheck_list))
biome_lib.last_count = #biome_lib.block_log
end
minetest.after(1, biome_lib.show_pending_block_count)

View File

@ -70,4 +70,10 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
end
end
if #biome_lib.block_recheck_list > 0 then
for i = 1, #biome_lib.block_recheck_list do
biome_lib.block_log[#biome_lib.block_log + 1] = table.copy(biome_lib.block_recheck_list[i])
end
end
biome_lib.block_recheck_list = {}
end)

View File

@ -19,6 +19,6 @@ read_globals = {
-- mods
"default", "mesecon", "digiline",
"screwdriver"
"screwdriver", "unified_inventory"
}

View File

@ -7,7 +7,7 @@ end
local function set_wielder_formspec(data, meta)
meta:set_string("formspec",
"invsize[8,"..(6+data.wield_inv_height)..";]"..
"size[8,"..(6+data.wield_inv_height)..";]"..
"item_image[0,0;1,1;"..data.name_base.."_off]"..
"label[1,0;"..minetest.formspec_escape(data.description).."]"..
"list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((8-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]"..