diff options
-rw-r--r-- | builtin/settingtypes.txt | 18 | ||||
-rw-r--r-- | src/mapgen/dungeongen.cpp | 19 | ||||
-rw-r--r-- | src/mapgen/dungeongen.h | 3 | ||||
-rw-r--r-- | src/mapgen/mapgen.cpp | 12 | ||||
-rw-r--r-- | src/mapgen/mapgen.h | 1 | ||||
-rw-r--r-- | src/mapgen/mapgen_carpathian.cpp | 34 | ||||
-rw-r--r-- | src/mapgen/mapgen_carpathian.h | 1 | ||||
-rw-r--r-- | src/mapgen/mapgen_flat.cpp | 16 | ||||
-rw-r--r-- | src/mapgen/mapgen_flat.h | 1 | ||||
-rw-r--r-- | src/mapgen/mapgen_fractal.cpp | 10 | ||||
-rw-r--r-- | src/mapgen/mapgen_fractal.h | 1 | ||||
-rw-r--r-- | src/mapgen/mapgen_v5.cpp | 24 | ||||
-rw-r--r-- | src/mapgen/mapgen_v5.h | 1 | ||||
-rw-r--r-- | src/mapgen/mapgen_v6.cpp | 90 | ||||
-rw-r--r-- | src/mapgen/mapgen_v6.h | 2 | ||||
-rw-r--r-- | src/mapgen/mapgen_v7.cpp | 12 | ||||
-rw-r--r-- | src/mapgen/mapgen_v7.h | 1 | ||||
-rw-r--r-- | src/mapgen/mapgen_valleys.cpp | 12 | ||||
-rw-r--r-- | src/mapgen/mapgen_valleys.h | 1 |
19 files changed, 159 insertions, 100 deletions
diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index f0ba434a2..911d247a2 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -1417,6 +1417,9 @@ mgv5_np_cavern (Cavern noise) noise_params_3d 0, 1, (384, 128, 384), 723, 5, 0.6 # 3D noise defining terrain. mgv5_np_ground (Ground noise) noise_params_3d 0, 40, (80, 80, 80), 983240, 4, 0.55, 2.0, eased +# 3D noise that determines number of dungeons per mapchunk. +mgv5_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500), 0, 2, 0.8, 2.0 + [*Mapgen V6] # Map generation attributes specific to Mapgen v6. @@ -1569,6 +1572,9 @@ mgv7_np_cave1 (Cave1 noise) noise_params_3d 0, 12, (61, 61, 61), 52534, 3, 0.5, # Second of two 3D noises that together define tunnels. mgv7_np_cave2 (Cave2 noise) noise_params_3d 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +# 3D noise that determines number of dungeons per mapchunk. +mgv7_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500), 0, 2, 0.8, 2.0 + [*Mapgen Carpathian] # Map generation attributes specific to Mapgen Carpathian. @@ -1648,6 +1654,9 @@ mgcarpathian_np_cave2 (Cave2 noise) noise_params_3d 0, 12, (67, 67, 67), 10325, # 3D noise defining giant caverns. mgcarpathian_np_cavern (Cavern noise) noise_params_3d 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0 +# 3D noise that determines number of dungeons per mapchunk. +mgcarpathian_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500), 0, 2, 0.8, 2.0 + [*Mapgen Flat] # Map generation attributes specific to Mapgen flat. @@ -1702,6 +1711,9 @@ mgflat_np_cave1 (Cave1 noise) noise_params_3d 0, 12, (61, 61, 61), 52534, 3, 0.5 # Second of two 3D noises that together define tunnels. mgflat_np_cave2 (Cave2 noise) noise_params_3d 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +# 3D noise that determines number of dungeons per mapchunk. +mgflat_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500), 0, 2, 0.8, 2.0 + [*Mapgen Fractal] # Controls width of tunnels, a smaller value creates wider tunnels. @@ -1811,6 +1823,9 @@ mgfractal_np_cave1 (Cave1 noise) noise_params_3d 0, 12, (61, 61, 61), 52534, 3, # Second of two 3D noises that together define tunnels. mgfractal_np_cave2 (Cave2 noise) noise_params_3d 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0 +# 3D noise that determines number of dungeons per mapchunk. +mgfractal_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500), 0, 2, 0.8, 2.0 + [*Mapgen Valleys] # Map generation attributes specific to Mapgen Valleys. @@ -1888,6 +1903,9 @@ mgvalleys_np_valley_profile (Valley profile) noise_params_2d 0.6, 0.5, (512, 512 # Slope and fill work together to modify the heights. mgvalleys_np_inter_valley_slope (Valley slope) noise_params_2d 0.5, 0.5, (128, 128, 128), 746, 1, 1.0, 2.0, eased +# 3D noise that determines number of dungeons per mapchunk. +mgvalleys_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500), 0, 2, 0.8, 2.0 + [*Advanced] # Size of mapchunks generated by mapgen, stated in mapblocks (16 nodes). diff --git a/src/mapgen/dungeongen.cpp b/src/mapgen/dungeongen.cpp index 1aa3317cf..1cb46f140 100644 --- a/src/mapgen/dungeongen.cpp +++ b/src/mapgen/dungeongen.cpp @@ -31,9 +31,6 @@ with this program; if not, write to the Free Software Foundation, Inc., //#define DGEN_USE_TORCHES -NoiseParams nparams_dungeon_density(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0); -NoiseParams nparams_dungeon_alt_wall(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0); - /////////////////////////////////////////////////////////////////////////////// @@ -73,22 +70,22 @@ DungeonGen::DungeonGen(const NodeDefManager *ndef, dp.rooms_max = 16; dp.notifytype = GENNOTIFY_DUNGEON; - dp.np_density = nparams_dungeon_density; - dp.np_alt_wall = nparams_dungeon_alt_wall; + dp.np_alt_wall = + NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0); } } -void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax) +void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax, + u16 num_dungeons) { + if (num_dungeons == 0) + return; + assert(vm); //TimeTaker t("gen dungeons"); - float nval_density = NoisePerlin3D(&dp.np_density, nmin.X, nmin.Y, nmin.Z, dp.seed); - if (nval_density < 1.0f) - return; - static const bool preserve_ignore = !g_settings->getBool("projecting_dungeons"); this->vm = vm; @@ -122,7 +119,7 @@ void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax) } // Add them - for (u32 i = 0; i < std::floor(nval_density); i++) + for (u32 i = 0; i < num_dungeons; i++) makeDungeon(v3s16(1, 1, 1) * MAP_BLOCKSIZE); // Optionally convert some structure to alternative structure diff --git a/src/mapgen/dungeongen.h b/src/mapgen/dungeongen.h index 7d04a6254..2c20446fd 100644 --- a/src/mapgen/dungeongen.h +++ b/src/mapgen/dungeongen.h @@ -58,7 +58,6 @@ struct DungeonParams { u16 rooms_max; GenNotifyType notifytype; - NoiseParams np_density; NoiseParams np_alt_wall; }; @@ -83,7 +82,7 @@ public: GenerateNotifier *gennotify, DungeonParams *dparams); void generate(MMVManip *vm, u32 bseed, - v3s16 full_node_min, v3s16 full_node_max); + v3s16 full_node_min, v3s16 full_node_max, u16 num_dungeons); void makeDungeon(v3s16 start_padding); void makeRoom(v3s16 roomsize, v3s16 roomplace); diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp index bdbbc01f7..c4aaff00d 100644 --- a/src/mapgen/mapgen.cpp +++ b/src/mapgen/mapgen.cpp @@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include <cmath> #include "mapgen.h" #include "voxel.h" #include "noise.h" @@ -889,6 +890,11 @@ void MapgenBasic::generateDungeons(s16 max_stone_y) if (max_stone_y < node_min.Y) return; + u16 num_dungeons = std::fmax(std::floor( + NoisePerlin3D(&np_dungeons, node_min.X, node_min.Y, node_min.Z, seed)), 0.0f); + if (num_dungeons == 0) + return; + // Get biome at mapchunk midpoint v3s16 chunk_mid = node_min + (node_max - node_min) / v3s16(2, 2, 2); Biome *biome = (Biome *)biomegen->getBiomeAtPoint(chunk_mid); @@ -902,8 +908,8 @@ void MapgenBasic::generateDungeons(s16 max_stone_y) dp.rooms_min = 2; dp.rooms_max = 16; - dp.np_density = nparams_dungeon_density; - dp.np_alt_wall = nparams_dungeon_alt_wall; + dp.np_alt_wall = + NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0); // Biome-defined dungeon nodes if (biome->c_dungeon != CONTENT_IGNORE) { @@ -980,7 +986,7 @@ void MapgenBasic::generateDungeons(s16 max_stone_y) } DungeonGen dgen(ndef, &gennotify, &dp); - dgen.generate(vm, blockseed, full_node_min, full_node_max); + dgen.generate(vm, blockseed, full_node_min, full_node_max, num_dungeons); } diff --git a/src/mapgen/mapgen.h b/src/mapgen/mapgen.h index 414c011d9..2fc3aed95 100644 --- a/src/mapgen/mapgen.h +++ b/src/mapgen/mapgen.h @@ -283,6 +283,7 @@ protected: NoiseParams np_cave1; NoiseParams np_cave2; NoiseParams np_cavern; + NoiseParams np_dungeons; float cave_width; float cavern_limit; float cavern_taper; diff --git a/src/mapgen/mapgen_carpathian.cpp b/src/mapgen/mapgen_carpathian.cpp index 3a69fb5b8..b8107e973 100644 --- a/src/mapgen/mapgen_carpathian.cpp +++ b/src/mapgen/mapgen_carpathian.cpp @@ -88,6 +88,7 @@ MapgenCarpathian::MapgenCarpathian(MapgenCarpathianParams *params, EmergeManager MapgenBasic::np_cave1 = params->np_cave1; MapgenBasic::np_cave2 = params->np_cave2; MapgenBasic::np_cavern = params->np_cavern; + MapgenBasic::np_dungeons = params->np_dungeons; } @@ -109,21 +110,22 @@ MapgenCarpathian::~MapgenCarpathian() MapgenCarpathianParams::MapgenCarpathianParams(): - np_filler_depth (0, 1, v3f(128, 128, 128), 261, 3, 0.7, 2.0), - np_height1 (0, 5, v3f(251, 251, 251), 9613, 5, 0.5, 2.0), - np_height2 (0, 5, v3f(383, 383, 383), 1949, 5, 0.5, 2.0), - np_height3 (0, 5, v3f(509, 509, 509), 3211, 5, 0.5, 2.0), - np_height4 (0, 5, v3f(631, 631, 631), 1583, 5, 0.5, 2.0), - np_hills_terrain (1, 1, v3f(1301, 1301, 1301), 1692, 5, 0.5, 2.0), - np_ridge_terrain (1, 1, v3f(1889, 1889, 1889), 3568, 5, 0.5, 2.0), - np_step_terrain (1, 1, v3f(1889, 1889, 1889), 4157, 5, 0.5, 2.0), - np_hills (0, 3, v3f(257, 257, 257), 6604, 6, 0.5, 2.0), - np_ridge_mnt (0, 12, v3f(743, 743, 743), 5520, 6, 0.7, 2.0), - np_step_mnt (0, 8, v3f(509, 509, 509), 2590, 6, 0.6, 2.0), - np_mnt_var (0, 1, v3f(499, 499, 499), 2490, 5, 0.55, 2.0), - np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), - np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), - np_cavern (0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0) + np_filler_depth (0, 1, v3f(128, 128, 128), 261, 3, 0.7, 2.0), + np_height1 (0, 5, v3f(251, 251, 251), 9613, 5, 0.5, 2.0), + np_height2 (0, 5, v3f(383, 383, 383), 1949, 5, 0.5, 2.0), + np_height3 (0, 5, v3f(509, 509, 509), 3211, 5, 0.5, 2.0), + np_height4 (0, 5, v3f(631, 631, 631), 1583, 5, 0.5, 2.0), + np_hills_terrain (1, 1, v3f(1301, 1301, 1301), 1692, 5, 0.5, 2.0), + np_ridge_terrain (1, 1, v3f(1889, 1889, 1889), 3568, 5, 0.5, 2.0), + np_step_terrain (1, 1, v3f(1889, 1889, 1889), 4157, 5, 0.5, 2.0), + np_hills (0, 3, v3f(257, 257, 257), 6604, 6, 0.5, 2.0), + np_ridge_mnt (0, 12, v3f(743, 743, 743), 5520, 6, 0.7, 2.0), + np_step_mnt (0, 8, v3f(509, 509, 509), 2590, 6, 0.6, 2.0), + np_mnt_var (0, 1, v3f(499, 499, 499), 2490, 5, 0.55, 2.0), + np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), + np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), + np_cavern (0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0), + np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0) { } @@ -156,6 +158,7 @@ void MapgenCarpathianParams::readParams(const Settings *settings) settings->getNoiseParams("mgcarpathian_np_cave1", np_cave1); settings->getNoiseParams("mgcarpathian_np_cave2", np_cave2); settings->getNoiseParams("mgcarpathian_np_cavern", np_cavern); + settings->getNoiseParams("mgcarpathian_np_dungeons", np_dungeons); } @@ -187,6 +190,7 @@ void MapgenCarpathianParams::writeParams(Settings *settings) const settings->setNoiseParams("mgcarpathian_np_cave1", np_cave1); settings->setNoiseParams("mgcarpathian_np_cave2", np_cave2); settings->setNoiseParams("mgcarpathian_np_cavern", np_cavern); + settings->setNoiseParams("mgcarpathian_np_dungeons", np_dungeons); } diff --git a/src/mapgen/mapgen_carpathian.h b/src/mapgen/mapgen_carpathian.h index 3f61b7d22..89dfaa7de 100644 --- a/src/mapgen/mapgen_carpathian.h +++ b/src/mapgen/mapgen_carpathian.h @@ -60,6 +60,7 @@ struct MapgenCarpathianParams : public MapgenParams NoiseParams np_cave1; NoiseParams np_cave2; NoiseParams np_cavern; + NoiseParams np_dungeons; MapgenCarpathianParams(); ~MapgenCarpathianParams() = default; diff --git a/src/mapgen/mapgen_flat.cpp b/src/mapgen/mapgen_flat.cpp index e31dc4703..d859fa973 100644 --- a/src/mapgen/mapgen_flat.cpp +++ b/src/mapgen/mapgen_flat.cpp @@ -69,8 +69,9 @@ MapgenFlat::MapgenFlat(MapgenFlatParams *params, EmergeManager *emerge) if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS)) noise_terrain = new Noise(¶ms->np_terrain, seed, csize.X, csize.Z); // 3D noise - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_dungeons = params->np_dungeons; } @@ -84,10 +85,11 @@ MapgenFlat::~MapgenFlat() MapgenFlatParams::MapgenFlatParams(): - np_terrain (0, 1, v3f(600, 600, 600), 7244, 5, 0.6, 2.0), - np_filler_depth (0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0), - np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), - np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0) + np_terrain (0, 1, v3f(600, 600, 600), 7244, 5, 0.6, 2.0), + np_filler_depth (0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0), + np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), + np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), + np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0) { } @@ -110,6 +112,7 @@ void MapgenFlatParams::readParams(const Settings *settings) settings->getNoiseParams("mgflat_np_filler_depth", np_filler_depth); settings->getNoiseParams("mgflat_np_cave1", np_cave1); settings->getNoiseParams("mgflat_np_cave2", np_cave2); + settings->getNoiseParams("mgflat_np_dungeons", np_dungeons); } @@ -131,6 +134,7 @@ void MapgenFlatParams::writeParams(Settings *settings) const settings->setNoiseParams("mgflat_np_filler_depth", np_filler_depth); settings->setNoiseParams("mgflat_np_cave1", np_cave1); settings->setNoiseParams("mgflat_np_cave2", np_cave2); + settings->setNoiseParams("mgflat_np_dungeons", np_dungeons); } diff --git a/src/mapgen/mapgen_flat.h b/src/mapgen/mapgen_flat.h index e9bd611e4..d2598695f 100644 --- a/src/mapgen/mapgen_flat.h +++ b/src/mapgen/mapgen_flat.h @@ -48,6 +48,7 @@ struct MapgenFlatParams : public MapgenParams NoiseParams np_filler_depth; NoiseParams np_cave1; NoiseParams np_cave2; + NoiseParams np_dungeons; MapgenFlatParams(); ~MapgenFlatParams() = default; diff --git a/src/mapgen/mapgen_fractal.cpp b/src/mapgen/mapgen_fractal.cpp index 47699b8a2..8dcff726f 100644 --- a/src/mapgen/mapgen_fractal.cpp +++ b/src/mapgen/mapgen_fractal.cpp @@ -70,8 +70,9 @@ MapgenFractal::MapgenFractal(MapgenFractalParams *params, EmergeManager *emerge) noise_seabed = new Noise(¶ms->np_seabed, seed, csize.X, csize.Z); noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z); - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_dungeons = params->np_dungeons; formula = fractal / 2 + fractal % 2; julia = fractal % 2 == 0; @@ -89,7 +90,8 @@ MapgenFractalParams::MapgenFractalParams(): np_seabed (-14, 9, v3f(600, 600, 600), 41900, 5, 0.6, 2.0), np_filler_depth (0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0), np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), - np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0) + np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), + np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0) { } @@ -116,6 +118,7 @@ void MapgenFractalParams::readParams(const Settings *settings) settings->getNoiseParams("mgfractal_np_filler_depth", np_filler_depth); settings->getNoiseParams("mgfractal_np_cave1", np_cave1); settings->getNoiseParams("mgfractal_np_cave2", np_cave2); + settings->getNoiseParams("mgfractal_np_dungeons", np_dungeons); } @@ -141,6 +144,7 @@ void MapgenFractalParams::writeParams(Settings *settings) const settings->setNoiseParams("mgfractal_np_filler_depth", np_filler_depth); settings->setNoiseParams("mgfractal_np_cave1", np_cave1); settings->setNoiseParams("mgfractal_np_cave2", np_cave2); + settings->setNoiseParams("mgfractal_np_dungeons", np_dungeons); } diff --git a/src/mapgen/mapgen_fractal.h b/src/mapgen/mapgen_fractal.h index da250c1e9..8a8cf0c75 100644 --- a/src/mapgen/mapgen_fractal.h +++ b/src/mapgen/mapgen_fractal.h @@ -51,6 +51,7 @@ struct MapgenFractalParams : public MapgenParams NoiseParams np_filler_depth; NoiseParams np_cave1; NoiseParams np_cave2; + NoiseParams np_dungeons; MapgenFractalParams(); ~MapgenFractalParams() = default; diff --git a/src/mapgen/mapgen_v5.cpp b/src/mapgen/mapgen_v5.cpp index eded332ca..bf99fd335 100644 --- a/src/mapgen/mapgen_v5.cpp +++ b/src/mapgen/mapgen_v5.cpp @@ -67,9 +67,10 @@ MapgenV5::MapgenV5(MapgenV5Params *params, EmergeManager *emerge) // 1-up 1-down overgeneration noise_ground = new Noise(¶ms->np_ground, seed, csize.X, csize.Y + 2, csize.Z); // 1 down overgeneration - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; - MapgenBasic::np_cavern = params->np_cavern; + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cavern = params->np_cavern; + MapgenBasic::np_dungeons = params->np_dungeons; } @@ -83,13 +84,14 @@ MapgenV5::~MapgenV5() MapgenV5Params::MapgenV5Params(): - np_filler_depth (0, 1, v3f(150, 150, 150), 261, 4, 0.7, 2.0), - np_factor (0, 1, v3f(250, 250, 250), 920381, 3, 0.45, 2.0), - np_height (0, 10, v3f(250, 250, 250), 84174, 4, 0.5, 2.0), - np_ground (0, 40, v3f(80, 80, 80), 983240, 4, 0.55, 2.0, NOISE_FLAG_EASED), - np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), - np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), - np_cavern (0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0) + np_filler_depth (0, 1, v3f(150, 150, 150), 261, 4, 0.7, 2.0), + np_factor (0, 1, v3f(250, 250, 250), 920381, 3, 0.45, 2.0), + np_height (0, 10, v3f(250, 250, 250), 84174, 4, 0.5, 2.0), + np_ground (0, 40, v3f(80, 80, 80), 983240, 4, 0.55, 2.0, NOISE_FLAG_EASED), + np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), + np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), + np_cavern (0, 1, v3f(384, 128, 384), 723, 5, 0.63, 2.0), + np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0) { } @@ -113,6 +115,7 @@ void MapgenV5Params::readParams(const Settings *settings) settings->getNoiseParams("mgv5_np_cave1", np_cave1); settings->getNoiseParams("mgv5_np_cave2", np_cave2); settings->getNoiseParams("mgv5_np_cavern", np_cavern); + settings->getNoiseParams("mgv5_np_dungeons", np_dungeons); } @@ -135,6 +138,7 @@ void MapgenV5Params::writeParams(Settings *settings) const settings->setNoiseParams("mgv5_np_cave1", np_cave1); settings->setNoiseParams("mgv5_np_cave2", np_cave2); settings->setNoiseParams("mgv5_np_cavern", np_cavern); + settings->setNoiseParams("mgv5_np_dungeons", np_dungeons); } diff --git a/src/mapgen/mapgen_v5.h b/src/mapgen/mapgen_v5.h index 023d8308d..1a3b6d3c3 100644 --- a/src/mapgen/mapgen_v5.h +++ b/src/mapgen/mapgen_v5.h @@ -48,6 +48,7 @@ struct MapgenV5Params : public MapgenParams NoiseParams np_cave1; NoiseParams np_cave2; NoiseParams np_cavern; + NoiseParams np_dungeons; MapgenV5Params(); ~MapgenV5Params() = default; diff --git a/src/mapgen/mapgen_v6.cpp b/src/mapgen/mapgen_v6.cpp index 2b73c2975..9cf4da892 100644 --- a/src/mapgen/mapgen_v6.cpp +++ b/src/mapgen/mapgen_v6.cpp @@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., */ +#include <cmath> #include "mapgen.h" #include "voxel.h" #include "noise.h" @@ -59,7 +60,7 @@ MapgenV6::MapgenV6(MapgenV6Params *params, EmergeManager *emerge) : Mapgen(MAPGEN_V6, params, emerge) { m_emerge = emerge; - ystride = csize.X; //////fix this + ystride = csize.X; heightmap = new s16[csize.X * csize.Z]; @@ -74,6 +75,8 @@ MapgenV6::MapgenV6(MapgenV6Params *params, EmergeManager *emerge) np_trees = ¶ms->np_trees; np_apple_trees = ¶ms->np_apple_trees; + np_dungeons = NoiseParams(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0); + //// Create noise objects noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Y); noise_terrain_higher = new Noise(¶ms->np_terrain_higher, seed, csize.X, csize.Y); @@ -561,48 +564,51 @@ void MapgenV6::makeChunk(BlockMakeData *data) // Add dungeons if ((flags & MG_DUNGEONS) && stone_surface_max_y >= node_min.Y && full_node_min.Y >= dungeon_ymin && full_node_max.Y <= dungeon_ymax) { - DungeonParams dp; - - dp.seed = seed; - dp.only_in_ground = true; - dp.corridor_len_min = 1; - dp.corridor_len_max = 13; - dp.rooms_min = 2; - dp.rooms_max = 16; - - dp.np_density - = NoiseParams(0.9, 0.5, v3f(500.0, 500.0, 500.0), 0, 2, 0.8, 2.0); - dp.np_alt_wall - = NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0); - - if (getBiome(0, v2s16(node_min.X, node_min.Z)) == BT_DESERT) { - dp.c_wall = c_desert_stone; - dp.c_alt_wall = CONTENT_IGNORE; - dp.c_stair = c_stair_desert_stone; - - dp.diagonal_dirs = true; - dp.holesize = v3s16(2, 3, 2); - dp.room_size_min = v3s16(6, 9, 6); - dp.room_size_max = v3s16(10, 11, 10); - dp.room_size_large_min = v3s16(10, 13, 10); - dp.room_size_large_max = v3s16(18, 21, 18); - dp.notifytype = GENNOTIFY_TEMPLE; - } else { - dp.c_wall = c_cobble; - dp.c_alt_wall = c_mossycobble; - dp.c_stair = c_stair_cobble; - - dp.diagonal_dirs = false; - dp.holesize = v3s16(1, 2, 1); - dp.room_size_min = v3s16(4, 4, 4); - dp.room_size_max = v3s16(8, 6, 8); - dp.room_size_large_min = v3s16(8, 8, 8); - dp.room_size_large_max = v3s16(16, 16, 16); - dp.notifytype = GENNOTIFY_DUNGEON; - } + u16 num_dungeons = std::fmax(std::floor( + NoisePerlin3D(&np_dungeons, node_min.X, node_min.Y, node_min.Z, seed)), 0.0f); + + if (num_dungeons >= 1) { + DungeonParams dp; + + dp.seed = seed; + dp.only_in_ground = true; + dp.corridor_len_min = 1; + dp.corridor_len_max = 13; + dp.rooms_min = 2; + dp.rooms_max = 16; + + dp.np_alt_wall + = NoiseParams(-0.4, 1.0, v3f(40.0, 40.0, 40.0), 32474, 6, 1.1, 2.0); + + if (getBiome(0, v2s16(node_min.X, node_min.Z)) == BT_DESERT) { + dp.c_wall = c_desert_stone; + dp.c_alt_wall = CONTENT_IGNORE; + dp.c_stair = c_stair_desert_stone; + + dp.diagonal_dirs = true; + dp.holesize = v3s16(2, 3, 2); + dp.room_size_min = v3s16(6, 9, 6); + dp.room_size_max = v3s16(10, 11, 10); + dp.room_size_large_min = v3s16(10, 13, 10); + dp.room_size_large_max = v3s16(18, 21, 18); + dp.notifytype = GENNOTIFY_TEMPLE; + } else { + dp.c_wall = c_cobble; + dp.c_alt_wall = c_mossycobble; + dp.c_stair = c_stair_cobble; + + dp.diagonal_dirs = false; + dp.holesize = v3s16(1, 2, 1); + dp.room_size_min = v3s16(4, 4, 4); + dp.room_size_max = v3s16(8, 6, 8); + dp.room_size_large_min = v3s16(8, 8, 8); + dp.room_size_large_max = v3s16(16, 16, 16); + dp.notifytype = GENNOTIFY_DUNGEON; + } - DungeonGen dgen(ndef, &gennotify, &dp); - dgen.generate(vm, blockseed, full_node_min, full_node_max); + DungeonGen dgen(ndef, &gennotify, &dp); + dgen.generate(vm, blockseed, full_node_min, full_node_max, num_dungeons); + } } // Add top and bottom side of water to transforming_liquid queue diff --git a/src/mapgen/mapgen_v6.h b/src/mapgen/mapgen_v6.h index 842057903..7d5229559 100644 --- a/src/mapgen/mapgen_v6.h +++ b/src/mapgen/mapgen_v6.h @@ -108,6 +108,8 @@ public: NoiseParams *np_trees; NoiseParams *np_apple_trees; + NoiseParams np_dungeons; + float freq_desert; float freq_beach; s16 dungeon_ymin; diff --git a/src/mapgen/mapgen_v7.cpp b/src/mapgen/mapgen_v7.cpp index ad5220925..c9568760f 100644 --- a/src/mapgen/mapgen_v7.cpp +++ b/src/mapgen/mapgen_v7.cpp @@ -113,9 +113,10 @@ MapgenV7::MapgenV7(MapgenV7Params *params, EmergeManager *emerge) new Noise(¶ms->np_mountain, seed, csize.X, csize.Y + 2, csize.Z); // 3D noise, 1 down overgeneration - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; - MapgenBasic::np_cavern = params->np_cavern; + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cavern = params->np_cavern; + MapgenBasic::np_dungeons = params->np_dungeons; } @@ -159,7 +160,8 @@ MapgenV7Params::MapgenV7Params(): np_ridge (0.0, 1.0, v3f(100, 100, 100), 6467, 4, 0.75, 2.0), np_cavern (0.0, 1.0, v3f(384, 128, 384), 723, 5, 0.63, 2.0), np_cave1 (0.0, 12.0, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), - np_cave2 (0.0, 12.0, v3f(67, 67, 67), 10325, 3, 0.5, 2.0) + np_cave2 (0.0, 12.0, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), + np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0) { } @@ -196,6 +198,7 @@ void MapgenV7Params::readParams(const Settings *settings) settings->getNoiseParams("mgv7_np_cavern", np_cavern); settings->getNoiseParams("mgv7_np_cave1", np_cave1); settings->getNoiseParams("mgv7_np_cave2", np_cave2); + settings->getNoiseParams("mgv7_np_dungeons", np_dungeons); } @@ -231,6 +234,7 @@ void MapgenV7Params::writeParams(Settings *settings) const settings->setNoiseParams("mgv7_np_cavern", np_cavern); settings->setNoiseParams("mgv7_np_cave1", np_cave1); settings->setNoiseParams("mgv7_np_cave2", np_cave2); + settings->setNoiseParams("mgv7_np_dungeons", np_dungeons); } diff --git a/src/mapgen/mapgen_v7.h b/src/mapgen/mapgen_v7.h index f61da2b79..50039b16a 100644 --- a/src/mapgen/mapgen_v7.h +++ b/src/mapgen/mapgen_v7.h @@ -66,6 +66,7 @@ struct MapgenV7Params : public MapgenParams { NoiseParams np_cavern; NoiseParams np_cave1; NoiseParams np_cave2; + NoiseParams np_dungeons; MapgenV7Params(); ~MapgenV7Params() = default; diff --git a/src/mapgen/mapgen_valleys.cpp b/src/mapgen/mapgen_valleys.cpp index b8eb5b5f9..d0b36f29b 100644 --- a/src/mapgen/mapgen_valleys.cpp +++ b/src/mapgen/mapgen_valleys.cpp @@ -87,9 +87,10 @@ MapgenValleys::MapgenValleys(MapgenValleysParams *params, EmergeManager *emerge) noise_inter_valley_fill = new Noise(¶ms->np_inter_valley_fill, seed, csize.X, csize.Y + 2, csize.Z); // 1-down overgeneraion - MapgenBasic::np_cave1 = params->np_cave1; - MapgenBasic::np_cave2 = params->np_cave2; - MapgenBasic::np_cavern = params->np_cavern; + MapgenBasic::np_cave1 = params->np_cave1; + MapgenBasic::np_cave2 = params->np_cave2; + MapgenBasic::np_cavern = params->np_cavern; + MapgenBasic::np_dungeons = params->np_dungeons; } @@ -115,7 +116,8 @@ MapgenValleysParams::MapgenValleysParams(): np_valley_profile (0.6, 0.50, v3f(512, 512, 512), 777, 1, 1.0, 2.0), np_cave1 (0.0, 12.0, v3f(61, 61, 61), 52534, 3, 0.5, 2.0), np_cave2 (0.0, 12.0, v3f(67, 67, 67), 10325, 3, 0.5, 2.0), - np_cavern (0.0, 1.0, v3f(768, 256, 768), 59033, 6, 0.63, 2.0) + np_cavern (0.0, 1.0, v3f(768, 256, 768), 59033, 6, 0.63, 2.0), + np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0) { } @@ -146,6 +148,7 @@ void MapgenValleysParams::readParams(const Settings *settings) settings->getNoiseParams("mgvalleys_np_cave1", np_cave1); settings->getNoiseParams("mgvalleys_np_cave2", np_cave2); settings->getNoiseParams("mgvalleys_np_cavern", np_cavern); + settings->getNoiseParams("mgvalleys_np_dungeons", np_dungeons); } @@ -175,6 +178,7 @@ void MapgenValleysParams::writeParams(Settings *settings) const settings->setNoiseParams("mgvalleys_np_cave1", np_cave1); settings->setNoiseParams("mgvalleys_np_cave2", np_cave2); settings->setNoiseParams("mgvalleys_np_cavern", np_cavern); + settings->setNoiseParams("mgvalleys_np_dungeons", np_dungeons); } diff --git a/src/mapgen/mapgen_valleys.h b/src/mapgen/mapgen_valleys.h index fd40b5bab..ab80dc5c9 100644 --- a/src/mapgen/mapgen_valleys.h +++ b/src/mapgen/mapgen_valleys.h @@ -67,6 +67,7 @@ struct MapgenValleysParams : public MapgenParams { NoiseParams np_cave1; NoiseParams np_cave2; NoiseParams np_cavern; + NoiseParams np_dungeons; MapgenValleysParams(); ~MapgenValleysParams() = default; |