Add logging settings for mapgen and structures

mapgen logging being default off and structure generation default
on as the latter is the far more useful of the 2 in most situations
This commit is contained in:
cora 2022-09-13 01:14:02 +02:00
parent d531e8dc89
commit f8da4d9ee3
5 changed files with 34 additions and 23 deletions

View file

@ -24,7 +24,7 @@ mcl_mapgen_core.register_generator("end_island", function(vm, data, data2, emin,
data[idx] = c_end_stone
end
end
return true,true,true
return true,false,true
end, function(minp,maxp,blockseed)
local nn = minetest.find_nodes_in_area(minp,maxp,{"mcl_end:chorus_flower"})
local pr = PseudoRandom(blockseed)

View file

@ -3,11 +3,19 @@ local registered_generators = {}
local lvm, nodes, param2 = 0, 0, 0
local lvm_buffer = {}
local logging = minetest.settings:get_bool("mcl_logging_mapgen",false)
local function roundN(n, d)
if type(n) ~= "number" then return n end
local m = 10^d
return math.floor(n * m + 0.5) / m
end
minetest.register_on_generated(function(minp, maxp, blockseed)
minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp))
local t1 = os.clock()
local p1, p2 = {x=minp.x, y=minp.y, z=minp.z}, {x=maxp.x, y=maxp.y, z=maxp.z}
if lvm > 0 then
local lvm_used, shadow, deco_used = false, false
local lvm_used, shadow, deco_used = false, false, false
local lb2 = {} -- param2
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
local e1, e2 = {x=emin.x, y=emin.y, z=emin.z}, {x=emax.x, y=emax.y, z=emax.z}
@ -57,6 +65,9 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
end
mcl_vars.add_chunk(minp)
if logging then
minetest.log("action", "[mcl_mapgen_core] Generating chunk " .. minetest.pos_to_string(minp) .. " ... " .. minetest.pos_to_string(maxp).."..."..tostring(roundN(((os.clock() - t1)*1000),2)).."ms")
end
end)
function minetest.register_on_generated(node_function)

View file

@ -328,9 +328,6 @@ end
-- End block fixes:
-- * Replace water with end stone or air (depending on height).
-- * Remove stone, sand, dirt in v6 so our End map generator works in v6.
-- * Generate spawn platform (End portal destination)
local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blockseed)
if maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max then return end
local biomemap --ymin, ymax
@ -346,24 +343,18 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee
end
end
end
-- Final hackery: Set sun light level in the End.
-- -26912 is at a mapchunk border.
vm:set_lighting({day=15, night=15})
lvm_used = true
local shadow = true
if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then
shadow = false
end
return lvm_used, shadow
return true, false
end
mcl_mapgen_core.register_generator("world_structure", world_structure, nil, 1, true)
mcl_mapgen_core.register_generator("end_fixes", end_basic, nil, 20, true)
mcl_mapgen_core.register_generator("end_fixes", end_basic, function(minp,maxp)
if maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max then return end
end, 9999, true)
if mg_name ~= "v6" then
mcl_mapgen_core.register_generator("block_fixes", block_fixes, nil, 5, true)
mcl_mapgen_core.register_generator("block_fixes", block_fixes, nil, 9999, true)
end
if mg_name == "v6" then
@ -395,4 +386,5 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks
end
end
end
return false, false, false
end, 100, true)

View file

@ -4,6 +4,8 @@ local disabled_structures = minetest.settings:get("mcl_disabled_structures")
if disabled_structures then disabled_structures = disabled_structures:split(",")
else disabled_structures = {} end
local logging = minetest.settings:get_bool("mcl_logging_structures",true)
function mcl_structures.is_disabled(structname)
return table.indexof(disabled_structures,structname) ~= -1
end
@ -136,7 +138,7 @@ end
function mcl_structures.place_structure(pos, def, pr, blockseed)
if not def then return end
local logging = not def.terrain_feature
local log_enabled = logging and not def.terrain_feature
local y_offset = 0
if type(def.y_offset) == "function" then
y_offset = def.y_offset(pr)
@ -153,7 +155,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
if def.make_foundation then
foundation(vector.offset(pos,-def.sidelen/2 - 3,-1,-def.sidelen/2 - 3),vector.offset(pos,def.sidelen/2 + 3,-1,def.sidelen/2 + 3),pos,def.sidelen)
else
if logging then
if log_enabled then
minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pp).." not placed. No solid ground.")
end
return false
@ -161,7 +163,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
end
end
if def.on_place and not def.on_place(pos,def,pr,blockseed) then
if logging then
if log_enabled then
minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pp).." not placed. Conditions not satisfied.")
end
return false
@ -179,7 +181,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end
return ap(pp,def,pr,blockseed)
end,pr)
if logging then
if log_enabled then
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp))
end
return true
@ -188,13 +190,13 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
if not def.after_place or ( def.after_place and def.after_place(pp,def,pr,blockseed) ) then
if def.loot then generate_loot(pp,def,pr,blockseed) end
if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end
if logging then
if log_enabled then
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp))
end
return true
end
end
if logging then
if log_enabled then
minetest.log("warning","[mcl_structures] placing "..def.name.." failed at "..minetest.pos_to_string(pos))
end
end

View file

@ -197,3 +197,9 @@ mcl_item_id_debug (Item ID Debug) bool false
#Log mob spawning and despawning events
mcl_logging_mobs_spawn (Log Mob Spawning) bool true
# If enabled mapgen timings will be dumped to log
mcl_logging_mapgen (Chunk generation logging) bool false
# If enabled generated structures will be logged
mcl_logging_structures (Structure generation logging) bool true