Dungeons: Settable density noise, move number calculation to mapgens (#8473)
authorParamat <paramat@users.noreply.github.com>
Sat, 1 Jun 2019 19:50:43 +0000 (20:50 +0100)
committerGitHub <noreply@github.com>
Sat, 1 Jun 2019 19:50:43 +0000 (20:50 +0100)
Add user-settable noise parameters for dungeon density to each mapgen,
except V6 which hardcodes this noise parameter.

Move the calculation of number of dungeons generated in a mapchunk out
of dungeongen.cpp and into mapgen code, to allow mapgens to generate
any desired number of dungeons in a mapchunk, instead of being forced
to have number of dungeons determined by a density noise.

This is more flexible and allows mapgens to use dungeon generation to
create custom structures, such as occasional mega-dungeons.

19 files changed:
builtin/settingtypes.txt
src/mapgen/dungeongen.cpp
src/mapgen/dungeongen.h
src/mapgen/mapgen.cpp
src/mapgen/mapgen.h
src/mapgen/mapgen_carpathian.cpp
src/mapgen/mapgen_carpathian.h
src/mapgen/mapgen_flat.cpp
src/mapgen/mapgen_flat.h
src/mapgen/mapgen_fractal.cpp
src/mapgen/mapgen_fractal.h
src/mapgen/mapgen_v5.cpp
src/mapgen/mapgen_v5.h
src/mapgen/mapgen_v6.cpp
src/mapgen/mapgen_v6.h
src/mapgen/mapgen_v7.cpp
src/mapgen/mapgen_v7.h
src/mapgen/mapgen_valleys.cpp
src/mapgen/mapgen_valleys.h

index f0ba434a21bb4dcaa288b82feb1e9481cbf9ff0c..911d247a277272277c65cbee55a1c57ae0f93b63 100644 (file)
@@ -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).
index 1aa3317cf9ae6487c28e4b75f2a757907363b584..1cb46f1400a4e25fc4c97b17f5f5a56ba6dd61d0 100644 (file)
@@ -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
index 7d04a6254b94c6fc9d79e400c57158ccb58f8b1c..2c20446fd67b3303c878ec5900ba0e50d5a5f1f9 100644 (file)
@@ -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);
index bdbbc01f76b774bc26074a524babde87391e07ee..c4aaff00dd161e2f1dd1cba39dd1cfdd78687f36 100644 (file)
@@ -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);
 }
 
 
index 414c011d964245eda8bdfc0f3e3212dbba01f3b3..2fc3aed9522fca4963ee61144ddf292ebfd7ab84 100644 (file)
@@ -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;
index 3a69fb5b819a8e00affefff60882736c7af80674..b8107e973b884549804036d0d5a8b0632b8a4fec 100644 (file)
@@ -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);
 }
 
 
index 3f61b7d22e14481b52634371b31c9033758687a9..89dfaa7de23954af922bb369bf2ccd900c793910 100644 (file)
@@ -60,6 +60,7 @@ struct MapgenCarpathianParams : public MapgenParams
        NoiseParams np_cave1;
        NoiseParams np_cave2;
        NoiseParams np_cavern;
+       NoiseParams np_dungeons;
 
        MapgenCarpathianParams();
        ~MapgenCarpathianParams() = default;
index e31dc47033b395dc7e3f272c54133d629b9c1f0b..d859fa973012e48a5823766820d1f6c8dfa6db55 100644 (file)
@@ -69,8 +69,9 @@ MapgenFlat::MapgenFlat(MapgenFlatParams *params, EmergeManager *emerge)
        if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
                noise_terrain = new Noise(&params->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);
 }
 
 
index e9bd611e4026de2f87b5f820ec0f028816944099..d2598695ff1087b780e63598468f7300b0e85625 100644 (file)
@@ -48,6 +48,7 @@ struct MapgenFlatParams : public MapgenParams
        NoiseParams np_filler_depth;
        NoiseParams np_cave1;
        NoiseParams np_cave2;
+       NoiseParams np_dungeons;
 
        MapgenFlatParams();
        ~MapgenFlatParams() = default;
index 47699b8a28d786345abc53fd7cd9408efd799c8b..8dcff726f4e626197684607f10ee1ede6dcffef3 100644 (file)
@@ -70,8 +70,9 @@ MapgenFractal::MapgenFractal(MapgenFractalParams *params, EmergeManager *emerge)
        noise_seabed       = new Noise(&params->np_seabed, seed, csize.X, csize.Z);
        noise_filler_depth = new Noise(&params->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);
 }
 
 
index da250c1e9ac36c130e45f038216edc96f2775f6d..8a8cf0c75b0af30e6bc8aed9fbcdfba1f6a57ba2 100644 (file)
@@ -51,6 +51,7 @@ struct MapgenFractalParams : public MapgenParams
        NoiseParams np_filler_depth;
        NoiseParams np_cave1;
        NoiseParams np_cave2;
+       NoiseParams np_dungeons;
 
        MapgenFractalParams();
        ~MapgenFractalParams() = default;
index eded332cac52e262d8de575c3635e49ea8d1e4d8..bf99fd335634a94cc28e5d82fcaf7c7cac5e02fe 100644 (file)
@@ -67,9 +67,10 @@ MapgenV5::MapgenV5(MapgenV5Params *params, EmergeManager *emerge)
        // 1-up 1-down overgeneration
        noise_ground = new Noise(&params->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);
 }
 
 
index 023d8308d55072459b9e7b2a670d91156e9a703c..1a3b6d3c30e738e2bb0a7769bb4e788ebfeff951 100644 (file)
@@ -48,6 +48,7 @@ struct MapgenV5Params : public MapgenParams
        NoiseParams np_cave1;
        NoiseParams np_cave2;
        NoiseParams np_cavern;
+       NoiseParams np_dungeons;
 
        MapgenV5Params();
        ~MapgenV5Params() = default;
index 2b73c2975b1da15fdff944c163668605027d6146..9cf4da892e7eab4b5d2ee0dd3dae8496f94092d3 100644 (file)
@@ -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       = &params->np_trees;
        np_apple_trees = &params->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(&params->np_terrain_base,   seed, csize.X, csize.Y);
        noise_terrain_higher = new Noise(&params->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
index 8420579039fe629844ee2ac0becfd89f569a1e78..7d522955929744c68c12a89424b04fe1e3c04094 100644 (file)
@@ -108,6 +108,8 @@ public:
        NoiseParams *np_trees;
        NoiseParams *np_apple_trees;
 
+       NoiseParams np_dungeons;
+
        float freq_desert;
        float freq_beach;
        s16 dungeon_ymin;
index ad5220925f48341f5f8c95b68754f47a8ae9c52f..c9568760f2e1caaf02c1216001ecae0292adc39d 100644 (file)
@@ -113,9 +113,10 @@ MapgenV7::MapgenV7(MapgenV7Params *params, EmergeManager *emerge)
                        new Noise(&params->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);
 }
 
 
index f61da2b79c7149ffefcbf6c067b27347d213cd91..50039b16aad24067e9127d9954e28ce74d2d122a 100644 (file)
@@ -66,6 +66,7 @@ struct MapgenV7Params : public MapgenParams {
        NoiseParams np_cavern;
        NoiseParams np_cave1;
        NoiseParams np_cave2;
+       NoiseParams np_dungeons;
 
        MapgenV7Params();
        ~MapgenV7Params() = default;
index b8eb5b5f966b8d6b2e9861e10fc14147f18bb395..d0b36f29b98cbacc7b13e6395618ad3575caf915 100644 (file)
@@ -87,9 +87,10 @@ MapgenValleys::MapgenValleys(MapgenValleysParams *params, EmergeManager *emerge)
        noise_inter_valley_fill = new Noise(&params->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);
 }
 
 
index fd40b5bab03a0734844e81e5e06f0a6a71d38209..ab80dc5c9466b5d76de9fc6e3934af6596a99642 100644 (file)
@@ -67,6 +67,7 @@ struct MapgenValleysParams : public MapgenParams {
        NoiseParams np_cave1;
        NoiseParams np_cave2;
        NoiseParams np_cavern;
+       NoiseParams np_dungeons;
 
        MapgenValleysParams();
        ~MapgenValleysParams() = default;