mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-08-20 14:04:10 +02:00
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:
parent
d26793195f
commit
540bf56b91
@ -24,7 +24,7 @@ mcl_mapgen_core.register_generator("end_island", function(vm, data, data2, emin,
|
|||||||
data[idx] = c_end_stone
|
data[idx] = c_end_stone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true,true,true
|
return true,false,true
|
||||||
end, function(minp,maxp,blockseed)
|
end, function(minp,maxp,blockseed)
|
||||||
local nn = minetest.find_nodes_in_area(minp,maxp,{"mcl_end:chorus_flower"})
|
local nn = minetest.find_nodes_in_area(minp,maxp,{"mcl_end:chorus_flower"})
|
||||||
local pr = PseudoRandom(blockseed)
|
local pr = PseudoRandom(blockseed)
|
||||||
|
@ -3,11 +3,19 @@ local registered_generators = {}
|
|||||||
local lvm, nodes, param2 = 0, 0, 0
|
local lvm, nodes, param2 = 0, 0, 0
|
||||||
local lvm_buffer = {}
|
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.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}
|
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
|
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 lb2 = {} -- param2
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
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}
|
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
|
end
|
||||||
|
|
||||||
mcl_vars.add_chunk(minp)
|
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)
|
end)
|
||||||
|
|
||||||
function minetest.register_on_generated(node_function)
|
function minetest.register_on_generated(node_function)
|
||||||
|
@ -328,9 +328,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
-- End block fixes:
|
-- 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)
|
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
|
if maxp.y < mcl_vars.mg_end_min or minp.y > mcl_vars.mg_end_max then return end
|
||||||
local biomemap --ymin, ymax
|
local biomemap --ymin, ymax
|
||||||
@ -346,24 +343,18 @@ local function end_basic(vm, data, data2, emin, emax, area, minp, maxp, blocksee
|
|||||||
end
|
end
|
||||||
end
|
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})
|
vm:set_lighting({day=15, night=15})
|
||||||
lvm_used = true
|
return true, false
|
||||||
|
|
||||||
local shadow = true
|
|
||||||
if minp.y >= mcl_vars.mg_end_min and maxp.y <= -26911 then
|
|
||||||
shadow = false
|
|
||||||
end
|
|
||||||
return lvm_used, shadow
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
mcl_mapgen_core.register_generator("world_structure", world_structure, nil, 1, true)
|
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
|
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
|
end
|
||||||
|
|
||||||
if mg_name == "v6" then
|
if mg_name == "v6" then
|
||||||
@ -395,4 +386,5 @@ mcl_mapgen_core.register_generator("structures",nil, function(minp, maxp, blocks
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
return false, false, false
|
||||||
end, 100, true)
|
end, 100, true)
|
||||||
|
@ -4,6 +4,8 @@ local disabled_structures = minetest.settings:get("mcl_disabled_structures")
|
|||||||
if disabled_structures then disabled_structures = disabled_structures:split(",")
|
if disabled_structures then disabled_structures = disabled_structures:split(",")
|
||||||
else disabled_structures = {} end
|
else disabled_structures = {} end
|
||||||
|
|
||||||
|
local logging = minetest.settings:get_bool("mcl_logging_structures",true)
|
||||||
|
|
||||||
function mcl_structures.is_disabled(structname)
|
function mcl_structures.is_disabled(structname)
|
||||||
return table.indexof(disabled_structures,structname) ~= -1
|
return table.indexof(disabled_structures,structname) ~= -1
|
||||||
end
|
end
|
||||||
@ -136,7 +138,7 @@ end
|
|||||||
|
|
||||||
function mcl_structures.place_structure(pos, def, pr, blockseed)
|
function mcl_structures.place_structure(pos, def, pr, blockseed)
|
||||||
if not def then return end
|
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
|
local y_offset = 0
|
||||||
if type(def.y_offset) == "function" then
|
if type(def.y_offset) == "function" then
|
||||||
y_offset = def.y_offset(pr)
|
y_offset = def.y_offset(pr)
|
||||||
@ -153,7 +155,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
|
|||||||
if def.make_foundation then
|
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)
|
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
|
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.")
|
minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pp).." not placed. No solid ground.")
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
@ -161,7 +163,7 @@ function mcl_structures.place_structure(pos, def, pr, blockseed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if def.on_place and not def.on_place(pos,def,pr,blockseed) then
|
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.")
|
minetest.log("warning","[mcl_structures] "..def.name.." at "..minetest.pos_to_string(pp).." not placed. Conditions not satisfied.")
|
||||||
end
|
end
|
||||||
return false
|
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
|
if def.construct_nodes then construct_nodes(pp,def,pr,blockseed) end
|
||||||
return ap(pp,def,pr,blockseed)
|
return ap(pp,def,pr,blockseed)
|
||||||
end,pr)
|
end,pr)
|
||||||
if logging then
|
if log_enabled then
|
||||||
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp))
|
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp))
|
||||||
end
|
end
|
||||||
return true
|
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 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.loot then generate_loot(pp,def,pr,blockseed) end
|
||||||
if def.construct_nodes then construct_nodes(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))
|
minetest.log("action","[mcl_structures] "..def.name.." placed at "..minetest.pos_to_string(pp))
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if logging then
|
if log_enabled then
|
||||||
minetest.log("warning","[mcl_structures] placing "..def.name.." failed at "..minetest.pos_to_string(pos))
|
minetest.log("warning","[mcl_structures] placing "..def.name.." failed at "..minetest.pos_to_string(pos))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -197,3 +197,9 @@ mcl_item_id_debug (Item ID Debug) bool false
|
|||||||
|
|
||||||
#Log mob spawning and despawning events
|
#Log mob spawning and despawning events
|
||||||
mcl_logging_mobs_spawn (Log Mob Spawning) bool true
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user