From 302da3ec5155c5be1a29e781cd90b7e84274f831 Mon Sep 17 00:00:00 2001 From: FaceDeer Date: Fri, 29 Jul 2022 17:12:59 -0600 Subject: [PATCH] add location logging for debugging purposes --- chasms/init.lua | 10 +++++++++- df_caverns/lava_sea.lua | 8 ++++++++ df_caverns/level1.lua | 16 ++++++++++++++++ df_caverns/level2.lua | 19 ++++++++++++++++++- df_caverns/level3.lua | 23 +++++++++++++++++++++-- df_caverns/oil_sea.lua | 6 ++++++ df_caverns/primordial.lua | 18 ++++++++++++++++++ df_caverns/sunless_sea.lua | 12 ++++++++++++ df_caverns/underworld.lua | 10 +++++++++- df_trees/goblin_cap.lua | 9 +++++++++ df_trees/mod.conf | 2 +- mapgen_helper | 2 +- pit_caves/init.lua | 6 ++++++ 13 files changed, 134 insertions(+), 7 deletions(-) diff --git a/chasms/init.lua b/chasms/init.lua index ef59a71..1429926 100644 --- a/chasms/init.lua +++ b/chasms/init.lua @@ -78,6 +78,11 @@ end local c_air = minetest.get_content_id("air") local c_web +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + local big_webs_path = minetest.get_modpath("big_webs") if big_webs_path then c_web = minetest.get_content_id("big_webs:webbing") @@ -145,13 +150,16 @@ minetest.register_on_generated(function(minp, maxp, seed) webs = webs or calculate_web_array(minp, maxp) -- only calculate webs when we know we're in a chasm if webs[y + z*z_displace] and math.random() < 0.85 then -- random holes in the web data[i] = c_web - minetest.get_node_timer({x=x,y=y,z=z}):start(1) -- this timer will check for unsupported webs + local web_pos = vector.new(x,y,z) + minetest.get_node_timer(web_pos):start(1) -- this timer will check for unsupported webs + if log_location then log_location("chasm_web", web_pos) end else data[i] = c_air end else data[i] = c_air end + if log_location then log_location("chasm", vector.new(x,y,z)) end end end end diff --git a/df_caverns/lava_sea.lua b/df_caverns/lava_sea.lua index f9aca51..8e0c8d5 100644 --- a/df_caverns/lava_sea.lua +++ b/df_caverns/lava_sea.lua @@ -9,6 +9,10 @@ local c_mese_crystal = df_caverns.node_id.mese_crystal local c_mese_crystal_block = df_caverns.node_id.mese_crystal_block local c_obsidian = df_caverns.node_id.obsidian +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end ------------------------------------------------------------------------------------------- local perlin_cave = { @@ -84,6 +88,7 @@ minetest.register_on_generated(function(minp, maxp, seed) data[vi] = c_air else data[vi] = c_lava + if log_location then log_location("magma_sea", area:position(vi)) end end elseif y > floor_height - 5 and y < ceiling_height and y <= lava_height + 2 and not mapgen_helper.buildable_to(data[vi]) then data[vi] = c_obsidian -- thick obsidian floor @@ -112,13 +117,16 @@ minetest.register_on_generated(function(minp, maxp, seed) -- decorate ceiling if math.random() < 0.25 then data[vi] = c_meseore + if log_location then log_location("magma_sea_meseore", area:position(vi)) end elseif mese_intensity > 0.75 and math.random() < 0.1 then data[vi] = c_meseore local bi = vi-area.ystride data[bi] = c_mese_crystal data_param2[bi] = math.random(1,4) + 19 + if log_location then log_location("magma_sea_mesecrystal", area:position(vi)) end elseif mese_intensity > 0.85 and math.random() < 0.025 then subterrane.big_stalactite(vi-area.ystride, area, data, 6, 13, c_meseore, c_meseore, c_mese_crystal_block) + if log_location then log_location("magma_sea_mesebig", area:position(vi)) end end end end diff --git a/df_caverns/level1.lua b/df_caverns/level1.lua index cef223a..f452879 100644 --- a/df_caverns/level1.lua +++ b/df_caverns/level1.lua @@ -28,6 +28,11 @@ if minetest.get_modpath("df_farming") then } end +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + local subsea_level = df_caverns.config.level1_min - (df_caverns.config.level1_min - df_caverns.config.ymax) * 0.33 local flooding_threshold = math.min(df_caverns.config.tunnel_flooding_threshold, df_caverns.config.cavern_threshold) @@ -125,15 +130,20 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data) if minp.y < subsea_level and area:get_y(vi) < subsea_level and flooded_caverns then -- underwater floor df_caverns.flooded_cavern_floor(abs_cracks, vert_rand, vi, area, data) + if log_location then log_location("level1_flooded_"..biome_name, area:position(vi)) end elseif biome_name == "towercap" then tower_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level1_towercap", area:position(vi)) end elseif biome_name == "fungiwood" then fungiwood_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level1_fungiwood", area:position(vi)) end elseif biome_name == "barren" then if flooded_caverns then df_caverns.wet_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level1_barren_wet", area:position(vi)) end else df_caverns.dry_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level1_barren_dry", area:position(vi)) end end end end @@ -222,6 +232,12 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data) local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not. local ystride = area.ystride + if log_location then + local flood_name = "" + if flooded_caverns then flood_name = "_flooded" end + log_location("level1_warren_"..biome_name..flood_name, area:position(vi)) + end + if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then if flooded_caverns or biome_name ~= "barren" then -- we're in flooded areas or are not barren diff --git a/df_caverns/level2.lua b/df_caverns/level2.lua index ba0da9e..0f0eb55 100644 --- a/df_caverns/level2.lua +++ b/df_caverns/level2.lua @@ -16,6 +16,10 @@ local c_pearls = df_caverns.node_id.pearls local chasms_path = minetest.get_modpath("chasms") +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end local wall_vein_perlin_params = { offset = 0, @@ -168,6 +172,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data) if data[vi] == c_air and math.abs(vein_noise[vein_area:transform(area, vi)]) < 0.02 then data[vi] = c_veinstone end + if log_location then log_location("level2_veinstone", area:position(vi)) end end end if data[vi] == c_air and y <= subsea_level then @@ -189,18 +194,24 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data) if minp.y < subsea_level and area:get_y(vi) < subsea_level and flooded_caverns then -- underwater floor df_caverns.flooded_cavern_floor(abs_cracks, vert_rand, vi, area, data) + if log_location then log_location("level2_flooded_"..biome_name, area:position(vi)) end elseif biome_name == "barren" then if flooded_caverns then df_caverns.wet_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level2_barren_wet", area:position(vi)) end else df_caverns.dry_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level2_barren_dry", area:position(vi)) end end elseif biome_name == "goblincap" then - goblin_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + goblin_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level2_goblincap", area:position(vi)) end elseif biome_name == "sporetree" then spore_tree_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level2_sporetree", area:position(vi)) end elseif biome_name == "tunneltube" then tunnel_tube_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level2_tunneltube", area:position(vi)) end end end @@ -303,6 +314,12 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data) local biome_name = get_biome(heatmap[index2d], humiditymap[index2d]) local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not. + if log_location then + local flood_name = "" + if flooded_caverns then flood_name = "_flooded" end + log_location("level2_warren_"..biome_name..flood_name, area:position(vi)) + end + if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then if flooded_caverns or biome_name ~= "barren" then -- we're in flooded areas or are not barren diff --git a/df_caverns/level3.lua b/df_caverns/level3.lua index 8816245..a88c3ad 100644 --- a/df_caverns/level3.lua +++ b/df_caverns/level3.lua @@ -21,6 +21,11 @@ local c_webs_egg = df_caverns.node_id.big_webs_egg local chasms_path = minetest.get_modpath("chasms") +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + local subsea_level = math.floor(df_caverns.config.level3_min - (df_caverns.config.level3_min - df_caverns.config.level2_min) * 0.33) local flooding_threshold = math.min(df_caverns.config.tunnel_flooding_threshold, df_caverns.config.cavern_threshold) @@ -228,10 +233,12 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data) -- oil slick if y == subsea_level and data[vi] == c_water and math.abs(cave) + nvals_cracks[index2d]*0.025 < cavern_def.cave_threshold + 0.1 then data[vi] = c_oil + if log_location then log_location("level3_blackcap_oil", vector.new(x,y,z)) end end elseif biome_name == "bloodnether" and y <= subsea_level and y > subsea_level - ice_thickness and data[vi] == c_water then -- floating ice data[vi] = c_ice + if log_location then log_location("level3_nethercap_floating_ice", vector.new(x,y,z)) end end end end @@ -250,7 +257,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data) local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not. if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then - -- underwater floor + -- underwater floor. Not using df_caverns.flooded_cavern_floor to make level 3 water darker local ystride = area.ystride if abs_cracks > 0.25 and data[vi-ystride] ~= c_water then data[vi] = c_gravel @@ -261,10 +268,12 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data) subterrane.big_stalagmite(vi+ystride, area, data, 6, 15, c_wet_flowstone, c_wet_flowstone, c_wet_flowstone) end end + if log_location then log_location("level3_flooded_"..biome_name, area:position(vi)) end elseif biome_name == "barren" then if flooded_caverns then -- wet zone floor df_caverns.dry_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level3_barren_dry", area:position(vi)) end else -- dry zone floor, add crystals if abs_cracks < 0.075 then @@ -272,14 +281,18 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data) elseif abs_cracks > 0.3 and math.random() < 0.005 then df_mapitems.place_big_crystal_cluster(area, data, data_param2, vi+area.ystride, math.random(0,2), false) end + if log_location then log_location("level3_barren_wet", area:position(vi)) end end elseif biome_name == "blackcap" then - black_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + black_cap_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level3_blackcap", area:position(vi)) end elseif biome_name == "bloodnether" then if flooded_caverns then nether_cap_cavern_floor(cracks, abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level3_nethercap", area:position(vi)) end else blood_thorn_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("level3_bloodthorn", area:position(vi)) end end end end @@ -410,6 +423,12 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data) local biome_name = get_biome(heatmap[index2d], humiditymap[index2d]) local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not. + if log_location then + local flood_name = "" + if flooded_caverns then flood_name = "_flooded" end + log_location("level3_warren_"..biome_name..flood_name, area:position(vi)) + end + if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then -- underwater ceiling, do nothing elseif biome_name == "bloodnether" and flooded_caverns then diff --git a/df_caverns/oil_sea.lua b/df_caverns/oil_sea.lua index b16ef2f..dc6d40c 100644 --- a/df_caverns/oil_sea.lua +++ b/df_caverns/oil_sea.lua @@ -8,6 +8,11 @@ local c_gas_wisp = df_caverns.node_id.gas_wisp local c_lava = df_caverns.node_id.lava local c_obsidian = df_caverns.node_id.obsidian +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + ------------------------------------------------------------------------------------------- local perlin_cave = { @@ -86,6 +91,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end else data[vi] = c_oil + if log_location then log_location("oil_sea", area:position(vi)) end end end diff --git a/df_caverns/primordial.lua b/df_caverns/primordial.lua index 8f2be2c..3a5582a 100644 --- a/df_caverns/primordial.lua +++ b/df_caverns/primordial.lua @@ -4,6 +4,11 @@ end local c_air = df_caverns.node_id.air +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + local perlin_cave_primordial = { offset = 0, scale = 1, @@ -160,6 +165,16 @@ local jungle_cavern_floor = function(abs_cracks, humidity, vi, area, data, data_ local ystride = area.ystride local humidityfactor = humidity/100 + if log_location then + local pos = area:position(vi) + log_location("primordial_jungle", pos) + if humidityfactor < 0.25 then + log_location("primordial_jungle_low_humidity", pos) + elseif humidityfactor > 0.75 then + log_location("primordial_jungle_high_humidity", pos) + end + end + data[vi] = c_jungle_dirt local rand = math.random() @@ -278,6 +293,7 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da jungle_cavern_floor(abs_cracks, humidity, vi, area, data, data_param2) else mushroom_cavern_floor(abs_cracks, humidity, vi, area, data, data_param2) + if log_location then log_location("primordial_mushrooms", area:position(vi)) end end end @@ -337,8 +353,10 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da if jungle then jungle_warren_floor(abs_cracks, vi, area, data, data_param2) + if log_location then log_location("primordial_jungle_warren", area:position(vi)) end else mushroom_warren_floor(abs_cracks, vi, area, data, data_param2) + if log_location then log_location("primordial_mushroom_warren", area:position(vi)) end end end diff --git a/df_caverns/sunless_sea.lua b/df_caverns/sunless_sea.lua index 5f2137a..bb869c4 100644 --- a/df_caverns/sunless_sea.lua +++ b/df_caverns/sunless_sea.lua @@ -11,6 +11,11 @@ local c_obsidian = df_caverns.node_id.obsidian local chasms_path = minetest.get_modpath("chasms") +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + local c_coral_table = {} for node_name, node_def in pairs(minetest.registered_nodes) do if minetest.get_item_group(node_name, "dfcaverns_cave_coral") > 0 then @@ -231,6 +236,7 @@ local decorate_sunless_sea = function(minp, maxp, seed, vm, node_arrays, area, d end elseif y > floor_height and y < ceiling_height and data[vi] ~= c_wet_flowstone then data[vi] = c_air + if log_location then log_location("sunless_sea_river", vector.new(x,y,z)) end elseif y == ceiling_height and not mapgen_helper.buildable_to(data[vi]) then df_caverns.glow_worm_cavern_ceiling(math.abs(cracks), mapgen_helper.xz_consistent_randomi(area, vi), vi, area, data, data_param2) @@ -281,12 +287,16 @@ local decorate_sunless_sea = function(minp, maxp, seed, vm, node_arrays, area, d if y >= sea_level then if heat > hot_zone_boundary then hot_zone_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("sunless_sea_hot", area:position(vi)) end elseif heat > middle_zone_boundary then fungispore_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("sunless_sea_fungispore", area:position(vi)) end elseif heat > cool_zone_boundary then towergoblin_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("sunless_sea_towergoblin", area:position(vi)) end else cool_zone_floor(abs_cracks, vert_rand, vi, area, data, data_param2) + if log_location then log_location("sunless_sea_cool", area:position(vi)) end end elseif y >= sea_level - 30 then if math.random() < 0.005 then @@ -300,6 +310,7 @@ local decorate_sunless_sea = function(minp, maxp, seed, vm, node_arrays, area, d local iterations = math.random(1, 6) df_mapitems.spawn_coral_pile(area, data, vi, iterations) df_mapitems.spawn_castle_coral(area, data, vi+area.ystride, iterations) + if log_location then log_location("sunless_sea_castle_coral", area:position(vi)) end end end end @@ -383,6 +394,7 @@ local decorate_sunless_sea = function(minp, maxp, seed, vm, node_arrays, area, d for _, vi in ipairs(node_arrays.warren_floor_nodes) do if area:get_y(vi) >= sea_level and not mapgen_helper.buildable_to(data[vi]) then df_caverns.tunnel_floor(minp, maxp, area, vi, nvals_cracks, data, data_param2, true) + if log_location then log_location("sunless_sea_warren", area:position(vi)) end end end diff --git a/df_caverns/underworld.lua b/df_caverns/underworld.lua index ffe2d8b..01c81ed 100644 --- a/df_caverns/underworld.lua +++ b/df_caverns/underworld.lua @@ -11,6 +11,11 @@ local name_generator_path = minetest.get_modpath("name_generator") local hunters_enabled = minetest.get_modpath("hunter_statue") and df_underworld_items.config.underworld_hunter_statues +local log_location +if mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + local name_pit = function() end local name_ruin = function() end @@ -387,6 +392,7 @@ minetest.register_on_generated(function(minp, maxp, seed) if distance < pit.radius -2.5 then if y < median + floor_displace + wave - pit.depth or y < underside_height + plasma_depth_min then data[vi] = c_pit_plasma + if log_location then log_location("underworld_pit", vector.new(x,y,z)) end else data[vi] = c_air end @@ -471,7 +477,8 @@ minetest.register_on_generated(function(minp, maxp, seed) if not next(named_waypoints.get_waypoints_in_area("underworld_ruins", vector.subtract(building.pos, 250), vector.add(building.pos, 250))) then named_waypoints.add_waypoint("underworld_ruins", {x=building.pos.x, y=floor_height+1, z=building.pos.z}, {name=name_ruin()}) end - end + end + if log_location then log_location("underworld_building", building.pos) end elseif building.building_type == "small slab" then mapgen_helper.place_schematic_on_data(data, data_param2, area, building.pos, small_slab_schematic, building.rotation) else @@ -499,6 +506,7 @@ minetest.register_on_generated(function(minp, maxp, seed) end puzzle_seal = {x=minp.x+3, y=floor_height+1, z=minp.z+3} minetest.log("info", "Puzzle seal generated at " .. minetest.pos_to_string(puzzle_seal)) + if log_location then log_location("underworld_puzzle_seal", puzzle_seal) end end end diff --git a/df_trees/goblin_cap.lua b/df_trees/goblin_cap.lua index c549ae5..0f39a6e 100644 --- a/df_trees/goblin_cap.lua +++ b/df_trees/goblin_cap.lua @@ -1,6 +1,11 @@ local modpath = minetest.get_modpath(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname()) +local log_location +if minetest.get_modpath("mapgen_helper") and mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + --stem minetest.register_node("df_trees:goblin_cap_stem", { description = S("Goblin Cap Stem"), @@ -296,18 +301,22 @@ df_trees.spawn_goblin_cap_vm = function(vi, area, data, data_param2) local pos = area:position(vi) if math.random() < 0.5 then mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, big_goblin_cap_schem) + if log_location then log_location("goblin_cap_big", pos) end elseif math.random() < 0.9 then mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, bigger_goblin_cap_schem) + if log_location then log_location("goblin_cap_bigger", pos) end else -- easter egg - every once in a while (0.5%), a mapgen Goblin cap is a Smurf house minetest.after(5, init_hut, pos) if math.random() < 0.5 then mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, big_goblin_cap_hut_schem) + if log_location then log_location("goblin_cap_big_hut", pos) end else if init_vessels then minetest.after(5, init_vessels, pos) end mapgen_helper.place_schematic_on_data(data, data_param2, area, pos, bigger_goblin_cap_hut_schem) + if log_location then log_location("goblin_cap_bigger_hut", pos) end end end return diff --git a/df_trees/mod.conf b/df_trees/mod.conf index af4d486..a4f1b1c 100644 --- a/df_trees/mod.conf +++ b/df_trees/mod.conf @@ -1,4 +1,4 @@ name = df_trees description = Adds various types of underground fungal "trees". Light kills their saplings, they only grow in the dark. depends = default -optional_depends = doc, moreblocks, stairs, vessels, basic_materials, farming, doors, beds, df_farming \ No newline at end of file +optional_depends = doc, moreblocks, stairs, vessels, basic_materials, farming, doors, beds, df_farming, mapgen_helper \ No newline at end of file diff --git a/mapgen_helper b/mapgen_helper index 5fe751e..4e226f1 160000 --- a/mapgen_helper +++ b/mapgen_helper @@ -1 +1 @@ -Subproject commit 5fe751ea81b8a4e85479f4ed3aabede7fb060791 +Subproject commit 4e226f123772cd1239c0b37080ffb82020397c90 diff --git a/pit_caves/init.lua b/pit_caves/init.lua index 3e308fb..0e51f2c 100644 --- a/pit_caves/init.lua +++ b/pit_caves/init.lua @@ -28,6 +28,11 @@ if minetest.get_modpath("default") then end end +local log_location +if minetest.get_modpath("mapgen_helper") and mapgen_helper.log_location_enabled then + log_location = mapgen_helper.log_first_location +end + local ignore if minetest.get_modpath("chasms") then -- the chasms mod already sets up a method to allow chasms to avoid overwriting stalactites and whatnot, @@ -137,6 +142,7 @@ minetest.register_on_generated(function(minp, maxp, seed) data[vi] = c_gravel else data[vi] = c_air + if log_location then log_location("pit_cave", vector.new(x,y,z)) end end end end