diff options
Diffstat (limited to 'src/mapgen')
-rw-r--r-- | src/mapgen/cavegen.cpp | 35 | ||||
-rw-r--r-- | src/mapgen/cavegen.h | 8 | ||||
-rw-r--r-- | src/mapgen/mapgen.cpp | 47 | ||||
-rw-r--r-- | src/mapgen/mapgen.h | 24 | ||||
-rw-r--r-- | src/mapgen/mapgen_carpathian.cpp | 73 | ||||
-rw-r--r-- | src/mapgen/mapgen_carpathian.h | 26 | ||||
-rw-r--r-- | src/mapgen/mapgen_flat.cpp | 87 | ||||
-rw-r--r-- | src/mapgen/mapgen_flat.h | 11 | ||||
-rw-r--r-- | src/mapgen/mapgen_fractal.cpp | 116 | ||||
-rw-r--r-- | src/mapgen/mapgen_fractal.h | 12 | ||||
-rw-r--r-- | src/mapgen/mapgen_v5.cpp | 78 | ||||
-rw-r--r-- | src/mapgen/mapgen_v5.h | 12 | ||||
-rw-r--r-- | src/mapgen/mapgen_v6.cpp | 10 | ||||
-rw-r--r-- | src/mapgen/mapgen_v6.h | 3 | ||||
-rw-r--r-- | src/mapgen/mapgen_v7.cpp | 271 | ||||
-rw-r--r-- | src/mapgen/mapgen_v7.h | 28 | ||||
-rw-r--r-- | src/mapgen/mapgen_valleys.cpp | 78 | ||||
-rw-r--r-- | src/mapgen/mapgen_valleys.h | 13 |
18 files changed, 481 insertions, 451 deletions
diff --git a/src/mapgen/cavegen.cpp b/src/mapgen/cavegen.cpp index fa34b7273..a9df4506f 100644 --- a/src/mapgen/cavegen.cpp +++ b/src/mapgen/cavegen.cpp @@ -280,18 +280,18 @@ CavesRandomWalk::CavesRandomWalk( int water_level, content_t water_source, content_t lava_source, - int lava_depth, + float large_cave_flooded, BiomeGen *biomegen) { assert(ndef); - this->ndef = ndef; - this->gennotify = gennotify; - this->seed = seed; - this->water_level = water_level; - this->np_caveliquids = &nparams_caveliquids; - this->lava_depth = lava_depth; - this->bmgn = biomegen; + this->ndef = ndef; + this->gennotify = gennotify; + this->seed = seed; + this->water_level = water_level; + this->np_caveliquids = &nparams_caveliquids; + this->large_cave_flooded = large_cave_flooded; + this->bmgn = biomegen; c_water_source = water_source; if (c_water_source == CONTENT_IGNORE) @@ -322,7 +322,7 @@ void CavesRandomWalk::makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax, this->ystride = nmax.X - nmin.X + 1; - flooded = ps->range(1, 2) == 2; + flooded = ps->range(1, 1000) <= large_cave_flooded * 1000.0f; // If flooded: // Get biome at mapchunk midpoint. If cave liquid defined for biome, use it. @@ -364,12 +364,13 @@ void CavesRandomWalk::makeCave(MMVManip *vm, v3s16 nmin, v3s16 nmax, // Area starting point in nodes of = node_min; - // Allow a bit more - //(this should be more than the maximum radius of the tunnel) - const s16 insure = 10; + // Allow caves to extend up to 16 nodes beyond the mapchunk edge, to allow + // connecting with caves of neighbor mapchunks. + // 'insure' is needed to avoid many 'out of voxelmanip' cave nodes. + const s16 insure = 2; s16 more = MYMAX(MAP_BLOCKSIZE - max_tunnel_diameter / 2 - insure, 1); - ar += v3s16(1, 0, 1) * more * 2; - of -= v3s16(1, 0, 1) * more; + ar += v3s16(1, 1, 1) * more * 2; + of -= v3s16(1, 1, 1) * more; route_y_min = 0; // Allow half a diameter + 7 over stone surface @@ -527,12 +528,12 @@ void CavesRandomWalk::carveRoute(v3f vec, float f, bool randomize_xz) if (use_biome_liquid) { liquidnode = c_biome_liquid; } else { - // TODO remove this. Cave liquids are now defined and located using biome - // definitions. // If cave liquid not defined by biome, fallback to old hardcoded behaviour. + // TODO 'np_caveliquids' is deprecated and should eventually be removed. + // Cave liquids are now defined and located using biome definitions. float nval = NoisePerlin3D(np_caveliquids, startp.X, startp.Y, startp.Z, seed); - liquidnode = (nval < 0.40f && node_max.Y < lava_depth) ? + liquidnode = (nval < 0.40f && node_max.Y < water_level - 256) ? lavanode : waternode; } } diff --git a/src/mapgen/cavegen.h b/src/mapgen/cavegen.h index 3f1730ddb..ff09f9423 100644 --- a/src/mapgen/cavegen.h +++ b/src/mapgen/cavegen.h @@ -116,15 +116,13 @@ public: s16 *heightmap; BiomeGen *bmgn; - // configurable parameters s32 seed; int water_level; - // TODO 'lava_depth' and 'np_caveliquids' are deprecated and should be removed. + float large_cave_flooded; + // TODO 'np_caveliquids' is deprecated and should eventually be removed. // Cave liquids are now defined and located using biome definitions. - int lava_depth; NoiseParams *np_caveliquids; - // intermediate state variables u16 ystride; s16 min_tunnel_diameter; @@ -161,7 +159,7 @@ public: CavesRandomWalk(const NodeDefManager *ndef, GenerateNotifier *gennotify = NULL, s32 seed = 0, int water_level = 1, content_t water_source = CONTENT_IGNORE, content_t lava_source = CONTENT_IGNORE, - int lava_depth = -256, BiomeGen *biomegen = NULL); + float large_cave_flooded = 0.5f, BiomeGen *biomegen = NULL); // vm and ps are mandatory parameters. // If heightmap is NULL, the surface level at all points is assumed to diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp index 6d5e721ce..79c429ff6 100644 --- a/src/mapgen/mapgen.cpp +++ b/src/mapgen/mapgen.cpp @@ -215,6 +215,17 @@ void Mapgen::getMapgenNames(std::vector<const char *> *mgnames, bool include_hid } } +void Mapgen::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mg_flags", flagdesc_mapgen, + MG_CAVES | MG_DUNGEONS | MG_LIGHT | MG_DECORATIONS | MG_BIOMES); + + for (int i = 0; i < (int)MAPGEN_INVALID; ++i) { + MapgenParams *params = createMapgenParams((MapgenType)i); + params->setDefaultSettings(settings); + delete params; + } +} u32 Mapgen::getBlockSeed(v3s16 p, s32 seed) { @@ -831,7 +842,9 @@ void MapgenBasic::dustTopNodes() void MapgenBasic::generateCavesNoiseIntersection(s16 max_stone_y) { - if (node_min.Y > max_stone_y) + // cave_width >= 10 is used to disable generation and avoid the intensive + // 3D noise calculations. Tunnels already have zero width when cave_width > 1. + if (node_min.Y > max_stone_y || cave_width >= 10.0f) return; CavesNoiseIntersection caves_noise(ndef, m_bmgr, csize, @@ -841,20 +854,33 @@ void MapgenBasic::generateCavesNoiseIntersection(s16 max_stone_y) } -void MapgenBasic::generateCavesRandomWalk(s16 max_stone_y, s16 large_cave_depth) +void MapgenBasic::generateCavesRandomWalk(s16 max_stone_y, s16 large_cave_ymax) { - if (node_min.Y > max_stone_y || node_max.Y > large_cave_depth) + if (node_min.Y > max_stone_y) return; PseudoRandom ps(blockseed + 21343); - u32 bruises_count = ps.range(0, 2); + // Small randomwalk caves + u32 num_small_caves = ps.range(small_cave_num_min, small_cave_num_max); - for (u32 i = 0; i < bruises_count; i++) { + for (u32 i = 0; i < num_small_caves; i++) { CavesRandomWalk cave(ndef, &gennotify, seed, water_level, - c_water_source, c_lava_source, lava_depth, biomegen); + c_water_source, c_lava_source, large_cave_flooded, biomegen); + cave.makeCave(vm, node_min, node_max, &ps, false, max_stone_y, heightmap); + } + + if (node_max.Y > large_cave_ymax) + return; - cave.makeCave(vm, node_min, node_max, &ps, true, max_stone_y, - heightmap); + // Large randomwalk caves below 'large_cave_ymax'. + // 'large_cave_ymax' can differ from the 'large_cave_depth' mapgen parameter, + // it is set to world base to disable large caves in or near caverns. + u32 num_large_caves = ps.range(large_cave_num_min, large_cave_num_max); + + for (u32 i = 0; i < num_large_caves; i++) { + CavesRandomWalk cave(ndef, &gennotify, seed, water_level, + c_water_source, c_lava_source, large_cave_flooded, biomegen); + cave.makeCave(vm, node_min, node_max, &ps, true, max_stone_y, heightmap); } } @@ -873,7 +899,8 @@ bool MapgenBasic::generateCavernsNoise(s16 max_stone_y) void MapgenBasic::generateDungeons(s16 max_stone_y) { - if (max_stone_y < node_min.Y) + if (node_min.Y > max_stone_y || node_min.Y > dungeon_ymax || + node_max.Y < dungeon_ymin) return; u16 num_dungeons = std::fmax(std::floor( @@ -1052,7 +1079,7 @@ void MapgenParams::writeParams(Settings *settings) const settings->setS16("water_level", water_level); settings->setS16("mapgen_limit", mapgen_limit); settings->setS16("chunksize", chunksize); - settings->setFlagStr("mg_flags", flags, flagdesc_mapgen, U32_MAX); + settings->setFlagStr("mg_flags", flags, flagdesc_mapgen); if (bparams) bparams->writeParams(settings); diff --git a/src/mapgen/mapgen.h b/src/mapgen/mapgen.h index 0ac26d538..dc325c791 100644 --- a/src/mapgen/mapgen.h +++ b/src/mapgen/mapgen.h @@ -30,10 +30,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #define MAPGEN_DEFAULT_NAME "v7" /////////////////// Mapgen flags -#define MG_TREES 0x01 // Deprecated. Moved into mgv6 flags +#define MG_TREES 0x01 // Obsolete. Moved into mgv6 flags #define MG_CAVES 0x02 #define MG_DUNGEONS 0x04 -#define MG_FLAT 0x08 // Deprecated. Moved into mgv6 flags +#define MG_FLAT 0x08 // Obsolete. Moved into mgv6 flags #define MG_LIGHT 0x10 #define MG_DECORATIONS 0x20 #define MG_BIOMES 0x40 @@ -124,7 +124,9 @@ struct MapgenParams { u64 seed = 0; s16 water_level = 1; s16 mapgen_limit = MAX_MAP_GENERATION_LIMIT; - u32 flags = MG_CAVES | MG_LIGHT | MG_DECORATIONS | MG_BIOMES; + // Flags set in readParams + u32 flags = 0; + u32 spflags = 0; BiomeParams *bparams = nullptr; @@ -133,6 +135,8 @@ struct MapgenParams { virtual void readParams(const Settings *settings); virtual void writeParams(Settings *settings) const; + // Default settings for g_settings such as flags + virtual void setDefaultSettings(Settings *settings) {}; s32 getSpawnRangeMax(); @@ -214,6 +218,7 @@ public: EmergeManager *emerge); static MapgenParams *createMapgenParams(MapgenType mgtype); static void getMapgenNames(std::vector<const char *> *mgnames, bool include_hidden); + static void setDefaultSettings(Settings *settings); private: // isLiquidHorizontallyFlowable() is a helper function for updateLiquid() @@ -244,7 +249,7 @@ public: virtual void generateBiomes(); virtual void dustTopNodes(); virtual void generateCavesNoiseIntersection(s16 max_stone_y); - virtual void generateCavesRandomWalk(s16 max_stone_y, s16 large_cave_depth); + virtual void generateCavesRandomWalk(s16 max_stone_y, s16 large_cave_ymax); virtual bool generateCavernsNoise(s16 max_stone_y); virtual void generateDungeons(s16 max_stone_y); @@ -280,7 +285,12 @@ protected: float cavern_limit; float cavern_taper; float cavern_threshold; - // TODO 'lava_depth' is deprecated and should be removed. Cave liquids are - // now defined and located using biome definitions. - int lava_depth; + int small_cave_num_min; + int small_cave_num_max; + int large_cave_num_min; + int large_cave_num_max; + float large_cave_flooded; + s16 large_cave_depth; + s16 dungeon_ymin; + s16 dungeon_ymax; }; diff --git a/src/mapgen/mapgen_carpathian.cpp b/src/mapgen/mapgen_carpathian.cpp index 12ce07da4..0dc1d33be 100644 --- a/src/mapgen/mapgen_carpathian.cpp +++ b/src/mapgen/mapgen_carpathian.cpp @@ -58,15 +58,19 @@ MapgenCarpathian::MapgenCarpathian(MapgenCarpathianParams *params, EmergeManager river_depth = params->river_depth; valley_width = params->valley_width; - spflags = params->spflags; - cave_width = params->cave_width; - large_cave_depth = params->large_cave_depth; - lava_depth = params->lava_depth; - cavern_limit = params->cavern_limit; - cavern_taper = params->cavern_taper; - cavern_threshold = params->cavern_threshold; - dungeon_ymin = params->dungeon_ymin; - dungeon_ymax = params->dungeon_ymax; + spflags = params->spflags; + cave_width = params->cave_width; + large_cave_depth = params->large_cave_depth; + small_cave_num_min = params->small_cave_num_min; + small_cave_num_max = params->small_cave_num_max; + large_cave_num_min = params->large_cave_num_min; + large_cave_num_max = params->large_cave_num_max; + large_cave_flooded = params->large_cave_flooded; + cavern_limit = params->cavern_limit; + cavern_taper = params->cavern_taper; + cavern_threshold = params->cavern_threshold; + dungeon_ymin = params->dungeon_ymin; + dungeon_ymax = params->dungeon_ymax; grad_wl = 1 - water_level; @@ -148,14 +152,18 @@ void MapgenCarpathianParams::readParams(const Settings *settings) settings->getFloatNoEx("mgcarpathian_river_depth", river_depth); settings->getFloatNoEx("mgcarpathian_valley_width", valley_width); - settings->getFloatNoEx("mgcarpathian_cave_width", cave_width); - settings->getS16NoEx("mgcarpathian_large_cave_depth", large_cave_depth); - settings->getS16NoEx("mgcarpathian_lava_depth", lava_depth); - settings->getS16NoEx("mgcarpathian_cavern_limit", cavern_limit); - settings->getS16NoEx("mgcarpathian_cavern_taper", cavern_taper); - settings->getFloatNoEx("mgcarpathian_cavern_threshold", cavern_threshold); - settings->getS16NoEx("mgcarpathian_dungeon_ymin", dungeon_ymin); - settings->getS16NoEx("mgcarpathian_dungeon_ymax", dungeon_ymax); + settings->getFloatNoEx("mgcarpathian_cave_width", cave_width); + settings->getS16NoEx("mgcarpathian_large_cave_depth", large_cave_depth); + settings->getU16NoEx("mgcarpathian_small_cave_num_min", small_cave_num_min); + settings->getU16NoEx("mgcarpathian_small_cave_num_max", small_cave_num_max); + settings->getU16NoEx("mgcarpathian_large_cave_num_min", large_cave_num_min); + settings->getU16NoEx("mgcarpathian_large_cave_num_max", large_cave_num_max); + settings->getFloatNoEx("mgcarpathian_large_cave_flooded", large_cave_flooded); + settings->getS16NoEx("mgcarpathian_cavern_limit", cavern_limit); + settings->getS16NoEx("mgcarpathian_cavern_taper", cavern_taper); + settings->getFloatNoEx("mgcarpathian_cavern_threshold", cavern_threshold); + settings->getS16NoEx("mgcarpathian_dungeon_ymin", dungeon_ymin); + settings->getS16NoEx("mgcarpathian_dungeon_ymax", dungeon_ymax); settings->getNoiseParams("mgcarpathian_np_filler_depth", np_filler_depth); settings->getNoiseParams("mgcarpathian_np_height1", np_height1); @@ -179,21 +187,25 @@ void MapgenCarpathianParams::readParams(const Settings *settings) void MapgenCarpathianParams::writeParams(Settings *settings) const { - settings->setFlagStr("mgcarpathian_spflags", spflags, flagdesc_mapgen_carpathian, U32_MAX); + settings->setFlagStr("mgcarpathian_spflags", spflags, flagdesc_mapgen_carpathian); settings->setFloat("mgcarpathian_base_level", base_level); settings->setFloat("mgcarpathian_river_width", river_width); settings->setFloat("mgcarpathian_river_depth", river_depth); settings->setFloat("mgcarpathian_valley_width", valley_width); - settings->setFloat("mgcarpathian_cave_width", cave_width); - settings->setS16("mgcarpathian_large_cave_depth", large_cave_depth); - settings->setS16("mgcarpathian_lava_depth", lava_depth); - settings->setS16("mgcarpathian_cavern_limit", cavern_limit); - settings->setS16("mgcarpathian_cavern_taper", cavern_taper); - settings->setFloat("mgcarpathian_cavern_threshold", cavern_threshold); - settings->setS16("mgcarpathian_dungeon_ymin", dungeon_ymin); - settings->setS16("mgcarpathian_dungeon_ymax", dungeon_ymax); + settings->setFloat("mgcarpathian_cave_width", cave_width); + settings->setS16("mgcarpathian_large_cave_depth", large_cave_depth); + settings->setU16("mgcarpathian_small_cave_num_min", small_cave_num_min); + settings->setU16("mgcarpathian_small_cave_num_max", small_cave_num_max); + settings->setU16("mgcarpathian_large_cave_num_min", large_cave_num_min); + settings->setU16("mgcarpathian_large_cave_num_max", large_cave_num_max); + settings->setFloat("mgcarpathian_large_cave_flooded", large_cave_flooded); + settings->setS16("mgcarpathian_cavern_limit", cavern_limit); + settings->setS16("mgcarpathian_cavern_taper", cavern_taper); + settings->setFloat("mgcarpathian_cavern_threshold", cavern_threshold); + settings->setS16("mgcarpathian_dungeon_ymin", dungeon_ymin); + settings->setS16("mgcarpathian_dungeon_ymax", dungeon_ymax); settings->setNoiseParams("mgcarpathian_np_filler_depth", np_filler_depth); settings->setNoiseParams("mgcarpathian_np_height1", np_height1); @@ -215,6 +227,12 @@ void MapgenCarpathianParams::writeParams(Settings *settings) const } +void MapgenCarpathianParams::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mgcarpathian_spflags", flagdesc_mapgen_carpathian, + MGCARPATHIAN_CAVERNS); +} + //////////////////////////////////////////////////////////////////////////////// @@ -301,8 +319,7 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data) m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); // Generate dungeons - if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin && - full_node_max.Y <= dungeon_ymax) + if (flags & MG_DUNGEONS) generateDungeons(stone_surface_max_y); // Generate the registered decorations diff --git a/src/mapgen/mapgen_carpathian.h b/src/mapgen/mapgen_carpathian.h index 1fbac4bfd..acd379958 100644 --- a/src/mapgen/mapgen_carpathian.h +++ b/src/mapgen/mapgen_carpathian.h @@ -37,15 +37,18 @@ struct MapgenCarpathianParams : public MapgenParams float river_depth = 24.0f; float valley_width = 0.25f; - u32 spflags = MGCARPATHIAN_CAVERNS; - float cave_width = 0.09f; - s16 large_cave_depth = -33; - s16 lava_depth = -256; - s16 cavern_limit = -256; - s16 cavern_taper = 256; - float cavern_threshold = 0.7f; - s16 dungeon_ymin = -31000; - s16 dungeon_ymax = 31000; + float cave_width = 0.09f; + s16 large_cave_depth = -33; + u16 small_cave_num_min = 0; + u16 small_cave_num_max = 0; + u16 large_cave_num_min = 0; + u16 large_cave_num_max = 2; + float large_cave_flooded = 0.5f; + s16 cavern_limit = -256; + s16 cavern_taper = 256; + float cavern_threshold = 0.7f; + s16 dungeon_ymin = -31000; + s16 dungeon_ymax = 31000; NoiseParams np_filler_depth; NoiseParams np_height1; @@ -70,6 +73,7 @@ struct MapgenCarpathianParams : public MapgenParams void readParams(const Settings *settings); void writeParams(Settings *settings) const; + void setDefaultSettings(Settings *settings); }; class MapgenCarpathian : public MapgenBasic @@ -89,10 +93,6 @@ private: float river_depth; float valley_width; - s16 large_cave_depth; - s16 dungeon_ymin; - s16 dungeon_ymax; - Noise *noise_height1; Noise *noise_height2; Noise *noise_height3; diff --git a/src/mapgen/mapgen_flat.cpp b/src/mapgen/mapgen_flat.cpp index 773b7b10f..879435948 100644 --- a/src/mapgen/mapgen_flat.cpp +++ b/src/mapgen/mapgen_flat.cpp @@ -51,17 +51,21 @@ FlagDesc flagdesc_mapgen_flat[] = { MapgenFlat::MapgenFlat(MapgenFlatParams *params, EmergeManager *emerge) : MapgenBasic(MAPGEN_FLAT, params, emerge) { - spflags = params->spflags; - ground_level = params->ground_level; - large_cave_depth = params->large_cave_depth; - lava_depth = params->lava_depth; - cave_width = params->cave_width; - lake_threshold = params->lake_threshold; - lake_steepness = params->lake_steepness; - hill_threshold = params->hill_threshold; - hill_steepness = params->hill_steepness; - dungeon_ymin = params->dungeon_ymin; - dungeon_ymax = params->dungeon_ymax; + spflags = params->spflags; + ground_level = params->ground_level; + large_cave_depth = params->large_cave_depth; + small_cave_num_min = params->small_cave_num_min; + small_cave_num_max = params->small_cave_num_max; + large_cave_num_min = params->large_cave_num_min; + large_cave_num_max = params->large_cave_num_max; + large_cave_flooded = params->large_cave_flooded; + cave_width = params->cave_width; + lake_threshold = params->lake_threshold; + lake_steepness = params->lake_steepness; + hill_threshold = params->hill_threshold; + hill_steepness = params->hill_steepness; + dungeon_ymin = params->dungeon_ymin; + dungeon_ymax = params->dungeon_ymax; // 2D noise noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z); @@ -96,17 +100,21 @@ MapgenFlatParams::MapgenFlatParams(): void MapgenFlatParams::readParams(const Settings *settings) { - settings->getFlagStrNoEx("mgflat_spflags", spflags, flagdesc_mapgen_flat); - settings->getS16NoEx("mgflat_ground_level", ground_level); - settings->getS16NoEx("mgflat_large_cave_depth", large_cave_depth); - settings->getS16NoEx("mgflat_lava_depth", lava_depth); - settings->getFloatNoEx("mgflat_cave_width", cave_width); - settings->getFloatNoEx("mgflat_lake_threshold", lake_threshold); - settings->getFloatNoEx("mgflat_lake_steepness", lake_steepness); - settings->getFloatNoEx("mgflat_hill_threshold", hill_threshold); - settings->getFloatNoEx("mgflat_hill_steepness", hill_steepness); - settings->getS16NoEx("mgflat_dungeon_ymin", dungeon_ymin); - settings->getS16NoEx("mgflat_dungeon_ymax", dungeon_ymax); + settings->getFlagStrNoEx("mgflat_spflags", spflags, flagdesc_mapgen_flat); + settings->getS16NoEx("mgflat_ground_level", ground_level); + settings->getS16NoEx("mgflat_large_cave_depth", large_cave_depth); + settings->getU16NoEx("mgflat_small_cave_num_min", small_cave_num_min); + settings->getU16NoEx("mgflat_small_cave_num_max", small_cave_num_max); + settings->getU16NoEx("mgflat_large_cave_num_min", large_cave_num_min); + settings->getU16NoEx("mgflat_large_cave_num_max", large_cave_num_max); + settings->getFloatNoEx("mgflat_large_cave_flooded", large_cave_flooded); + settings->getFloatNoEx("mgflat_cave_width", cave_width); + settings->getFloatNoEx("mgflat_lake_threshold", lake_threshold); + settings->getFloatNoEx("mgflat_lake_steepness", lake_steepness); + settings->getFloatNoEx("mgflat_hill_threshold", hill_threshold); + settings->getFloatNoEx("mgflat_hill_steepness", hill_steepness); + settings->getS16NoEx("mgflat_dungeon_ymin", dungeon_ymin); + settings->getS16NoEx("mgflat_dungeon_ymax", dungeon_ymax); settings->getNoiseParams("mgflat_np_terrain", np_terrain); settings->getNoiseParams("mgflat_np_filler_depth", np_filler_depth); @@ -118,17 +126,21 @@ void MapgenFlatParams::readParams(const Settings *settings) void MapgenFlatParams::writeParams(Settings *settings) const { - settings->setFlagStr("mgflat_spflags", spflags, flagdesc_mapgen_flat, U32_MAX); - settings->setS16("mgflat_ground_level", ground_level); - settings->setS16("mgflat_large_cave_depth", large_cave_depth); - settings->setS16("mgflat_lava_depth", lava_depth); - settings->setFloat("mgflat_cave_width", cave_width); - settings->setFloat("mgflat_lake_threshold", lake_threshold); - settings->setFloat("mgflat_lake_steepness", lake_steepness); - settings->setFloat("mgflat_hill_threshold", hill_threshold); - settings->setFloat("mgflat_hill_steepness", hill_steepness); - settings->setS16("mgflat_dungeon_ymin", dungeon_ymin); - settings->setS16("mgflat_dungeon_ymax", dungeon_ymax); + settings->setFlagStr("mgflat_spflags", spflags, flagdesc_mapgen_flat); + settings->setS16("mgflat_ground_level", ground_level); + settings->setS16("mgflat_large_cave_depth", large_cave_depth); + settings->setU16("mgflat_small_cave_num_min", small_cave_num_min); + settings->setU16("mgflat_small_cave_num_max", small_cave_num_max); + settings->setU16("mgflat_large_cave_num_min", large_cave_num_min); + settings->setU16("mgflat_large_cave_num_max", large_cave_num_max); + settings->setFloat("mgflat_large_cave_flooded", large_cave_flooded); + settings->setFloat("mgflat_cave_width", cave_width); + settings->setFloat("mgflat_lake_threshold", lake_threshold); + settings->setFloat("mgflat_lake_steepness", lake_steepness); + settings->setFloat("mgflat_hill_threshold", hill_threshold); + settings->setFloat("mgflat_hill_steepness", hill_steepness); + settings->setS16("mgflat_dungeon_ymin", dungeon_ymin); + settings->setS16("mgflat_dungeon_ymax", dungeon_ymax); settings->setNoiseParams("mgflat_np_terrain", np_terrain); settings->setNoiseParams("mgflat_np_filler_depth", np_filler_depth); @@ -138,6 +150,12 @@ void MapgenFlatParams::writeParams(Settings *settings) const } +void MapgenFlatParams::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mgflat_spflags", flagdesc_mapgen_flat, 0); +} + + ///////////////////////////////////////////////////////////////// @@ -219,8 +237,7 @@ void MapgenFlat::makeChunk(BlockMakeData *data) // Generate the registered ores m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); - if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin && - full_node_max.Y <= dungeon_ymax) + if (flags & MG_DUNGEONS) generateDungeons(stone_surface_max_y); // Generate the registered decorations diff --git a/src/mapgen/mapgen_flat.h b/src/mapgen/mapgen_flat.h index d2598695f..c314c7605 100644 --- a/src/mapgen/mapgen_flat.h +++ b/src/mapgen/mapgen_flat.h @@ -32,10 +32,13 @@ extern FlagDesc flagdesc_mapgen_flat[]; struct MapgenFlatParams : public MapgenParams { - u32 spflags = 0; s16 ground_level = 8; s16 large_cave_depth = -33; - s16 lava_depth = -256; + u16 small_cave_num_min = 0; + u16 small_cave_num_max = 0; + u16 large_cave_num_min = 0; + u16 large_cave_num_max = 2; + float large_cave_flooded = 0.5f; float cave_width = 0.09f; float lake_threshold = -0.45f; float lake_steepness = 48.0f; @@ -55,6 +58,7 @@ struct MapgenFlatParams : public MapgenParams void readParams(const Settings *settings); void writeParams(Settings *settings) const; + void setDefaultSettings(Settings *settings); }; class MapgenFlat : public MapgenBasic @@ -71,13 +75,10 @@ public: private: s16 ground_level; - s16 large_cave_depth; float lake_threshold; float lake_steepness; float hill_threshold; float hill_steepness; - s16 dungeon_ymin; - s16 dungeon_ymax; Noise *noise_terrain; }; diff --git a/src/mapgen/mapgen_fractal.cpp b/src/mapgen/mapgen_fractal.cpp index 091dbacfa..96febb4f4 100644 --- a/src/mapgen/mapgen_fractal.cpp +++ b/src/mapgen/mapgen_fractal.cpp @@ -51,21 +51,25 @@ FlagDesc flagdesc_mapgen_fractal[] = { MapgenFractal::MapgenFractal(MapgenFractalParams *params, EmergeManager *emerge) : MapgenBasic(MAPGEN_FRACTAL, params, emerge) { - spflags = params->spflags; - cave_width = params->cave_width; - large_cave_depth = params->large_cave_depth; - lava_depth = params->lava_depth; - dungeon_ymin = params->dungeon_ymin; - dungeon_ymax = params->dungeon_ymax; - fractal = params->fractal; - iterations = params->iterations; - scale = params->scale; - offset = params->offset; - slice_w = params->slice_w; - julia_x = params->julia_x; - julia_y = params->julia_y; - julia_z = params->julia_z; - julia_w = params->julia_w; + spflags = params->spflags; + cave_width = params->cave_width; + large_cave_depth = params->large_cave_depth; + small_cave_num_min = params->small_cave_num_min; + small_cave_num_max = params->small_cave_num_max; + large_cave_num_min = params->large_cave_num_min; + large_cave_num_max = params->large_cave_num_max; + large_cave_flooded = params->large_cave_flooded; + dungeon_ymin = params->dungeon_ymin; + dungeon_ymax = params->dungeon_ymax; + fractal = params->fractal; + iterations = params->iterations; + scale = params->scale; + offset = params->offset; + slice_w = params->slice_w; + julia_x = params->julia_x; + julia_y = params->julia_y; + julia_z = params->julia_z; + julia_w = params->julia_w; //// 2D noise if (spflags & MGFRACTAL_TERRAIN) @@ -86,9 +90,7 @@ MapgenFractal::MapgenFractal(MapgenFractalParams *params, EmergeManager *emerge) MapgenFractal::~MapgenFractal() { - if (noise_seabed) - delete noise_seabed; - + delete noise_seabed; delete noise_filler_depth; } @@ -105,21 +107,25 @@ MapgenFractalParams::MapgenFractalParams(): void MapgenFractalParams::readParams(const Settings *settings) { - settings->getFlagStrNoEx("mgfractal_spflags", spflags, flagdesc_mapgen_fractal); - settings->getFloatNoEx("mgfractal_cave_width", cave_width); - settings->getS16NoEx("mgfractal_large_cave_depth", large_cave_depth); - settings->getS16NoEx("mgfractal_lava_depth", lava_depth); - settings->getS16NoEx("mgfractal_dungeon_ymin", dungeon_ymin); - settings->getS16NoEx("mgfractal_dungeon_ymax", dungeon_ymax); - settings->getU16NoEx("mgfractal_fractal", fractal); - settings->getU16NoEx("mgfractal_iterations", iterations); - settings->getV3FNoEx("mgfractal_scale", scale); - settings->getV3FNoEx("mgfractal_offset", offset); - settings->getFloatNoEx("mgfractal_slice_w", slice_w); - settings->getFloatNoEx("mgfractal_julia_x", julia_x); - settings->getFloatNoEx("mgfractal_julia_y", julia_y); - settings->getFloatNoEx("mgfractal_julia_z", julia_z); - settings->getFloatNoEx("mgfractal_julia_w", julia_w); + settings->getFlagStrNoEx("mgfractal_spflags", spflags, flagdesc_mapgen_fractal); + settings->getFloatNoEx("mgfractal_cave_width", cave_width); + settings->getS16NoEx("mgfractal_large_cave_depth", large_cave_depth); + settings->getU16NoEx("mgfractal_small_cave_num_min", small_cave_num_min); + settings->getU16NoEx("mgfractal_small_cave_num_max", small_cave_num_max); + settings->getU16NoEx("mgfractal_large_cave_num_min", large_cave_num_min); + settings->getU16NoEx("mgfractal_large_cave_num_max", large_cave_num_max); + settings->getFloatNoEx("mgfractal_large_cave_flooded", large_cave_flooded); + settings->getS16NoEx("mgfractal_dungeon_ymin", dungeon_ymin); + settings->getS16NoEx("mgfractal_dungeon_ymax", dungeon_ymax); + settings->getU16NoEx("mgfractal_fractal", fractal); + settings->getU16NoEx("mgfractal_iterations", iterations); + settings->getV3FNoEx("mgfractal_scale", scale); + settings->getV3FNoEx("mgfractal_offset", offset); + settings->getFloatNoEx("mgfractal_slice_w", slice_w); + settings->getFloatNoEx("mgfractal_julia_x", julia_x); + settings->getFloatNoEx("mgfractal_julia_y", julia_y); + settings->getFloatNoEx("mgfractal_julia_z", julia_z); + settings->getFloatNoEx("mgfractal_julia_w", julia_w); settings->getNoiseParams("mgfractal_np_seabed", np_seabed); settings->getNoiseParams("mgfractal_np_filler_depth", np_filler_depth); @@ -131,21 +137,25 @@ void MapgenFractalParams::readParams(const Settings *settings) void MapgenFractalParams::writeParams(Settings *settings) const { - settings->setFlagStr("mgfractal_spflags", spflags, flagdesc_mapgen_fractal, U32_MAX); - settings->setFloat("mgfractal_cave_width", cave_width); - settings->setS16("mgfractal_large_cave_depth", large_cave_depth); - settings->setS16("mgfractal_lava_depth", lava_depth); - settings->setS16("mgfractal_dungeon_ymin", dungeon_ymin); - settings->setS16("mgfractal_dungeon_ymax", dungeon_ymax); - settings->setU16("mgfractal_fractal", fractal); - settings->setU16("mgfractal_iterations", iterations); - settings->setV3F("mgfractal_scale", scale); - settings->setV3F("mgfractal_offset", offset); - settings->setFloat("mgfractal_slice_w", slice_w); - settings->setFloat("mgfractal_julia_x", julia_x); - settings->setFloat("mgfractal_julia_y", julia_y); - settings->setFloat("mgfractal_julia_z", julia_z); - settings->setFloat("mgfractal_julia_w", julia_w); + settings->setFlagStr("mgfractal_spflags", spflags, flagdesc_mapgen_fractal); + settings->setFloat("mgfractal_cave_width", cave_width); + settings->setS16("mgfractal_large_cave_depth", large_cave_depth); + settings->setU16("mgfractal_small_cave_num_min", small_cave_num_min); + settings->setU16("mgfractal_small_cave_num_max", small_cave_num_max); + settings->setU16("mgfractal_large_cave_num_min", large_cave_num_min); + settings->setU16("mgfractal_large_cave_num_max", large_cave_num_max); + settings->setFloat("mgfractal_large_cave_flooded", large_cave_flooded); + settings->setS16("mgfractal_dungeon_ymin", dungeon_ymin); + settings->setS16("mgfractal_dungeon_ymax", dungeon_ymax); + settings->setU16("mgfractal_fractal", fractal); + settings->setU16("mgfractal_iterations", iterations); + settings->setV3F("mgfractal_scale", scale); + settings->setV3F("mgfractal_offset", offset); + settings->setFloat("mgfractal_slice_w", slice_w); + settings->setFloat("mgfractal_julia_x", julia_x); + settings->setFloat("mgfractal_julia_y", julia_y); + settings->setFloat("mgfractal_julia_z", julia_z); + settings->setFloat("mgfractal_julia_w", julia_w); settings->setNoiseParams("mgfractal_np_seabed", np_seabed); settings->setNoiseParams("mgfractal_np_filler_depth", np_filler_depth); @@ -155,6 +165,13 @@ void MapgenFractalParams::writeParams(Settings *settings) const } +void MapgenFractalParams::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mgfractal_spflags", flagdesc_mapgen_fractal, + MGFRACTAL_TERRAIN); +} + + ///////////////////////////////////////////////////////////////// @@ -237,8 +254,7 @@ void MapgenFractal::makeChunk(BlockMakeData *data) m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); // Generate dungeons - if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin && - full_node_max.Y <= dungeon_ymax) + if (flags & MG_DUNGEONS) generateDungeons(stone_surface_max_y); // Generate the registered decorations diff --git a/src/mapgen/mapgen_fractal.h b/src/mapgen/mapgen_fractal.h index 82622d4d9..971dfd822 100644 --- a/src/mapgen/mapgen_fractal.h +++ b/src/mapgen/mapgen_fractal.h @@ -35,10 +35,13 @@ extern FlagDesc flagdesc_mapgen_fractal[]; struct MapgenFractalParams : public MapgenParams { - u32 spflags = MGFRACTAL_TERRAIN; float cave_width = 0.09f; s16 large_cave_depth = -33; - s16 lava_depth = -256; + u16 small_cave_num_min = 0; + u16 small_cave_num_max = 0; + u16 large_cave_num_min = 0; + u16 large_cave_num_max = 2; + float large_cave_flooded = 0.5f; s16 dungeon_ymin = -31000; s16 dungeon_ymax = 31000; u16 fractal = 1; @@ -62,6 +65,7 @@ struct MapgenFractalParams : public MapgenParams void readParams(const Settings *settings); void writeParams(Settings *settings) const; + void setDefaultSettings(Settings *settings); }; @@ -81,10 +85,6 @@ public: private: u16 formula; bool julia; - - s16 large_cave_depth; - s16 dungeon_ymin; - s16 dungeon_ymax; u16 fractal; u16 iterations; v3f scale; diff --git a/src/mapgen/mapgen_v5.cpp b/src/mapgen/mapgen_v5.cpp index bf99fd335..447fe8c50 100644 --- a/src/mapgen/mapgen_v5.cpp +++ b/src/mapgen/mapgen_v5.cpp @@ -48,15 +48,19 @@ FlagDesc flagdesc_mapgen_v5[] = { MapgenV5::MapgenV5(MapgenV5Params *params, EmergeManager *emerge) : MapgenBasic(MAPGEN_V5, params, emerge) { - spflags = params->spflags; - cave_width = params->cave_width; - large_cave_depth = params->large_cave_depth; - lava_depth = params->lava_depth; - cavern_limit = params->cavern_limit; - cavern_taper = params->cavern_taper; - cavern_threshold = params->cavern_threshold; - dungeon_ymin = params->dungeon_ymin; - dungeon_ymax = params->dungeon_ymax; + spflags = params->spflags; + cave_width = params->cave_width; + large_cave_depth = params->large_cave_depth; + small_cave_num_min = params->small_cave_num_min; + small_cave_num_max = params->small_cave_num_max; + large_cave_num_min = params->large_cave_num_min; + large_cave_num_max = params->large_cave_num_max; + large_cave_flooded = params->large_cave_flooded; + cavern_limit = params->cavern_limit; + cavern_taper = params->cavern_taper; + cavern_threshold = params->cavern_threshold; + dungeon_ymin = params->dungeon_ymin; + dungeon_ymax = params->dungeon_ymax; // Terrain noise noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z); @@ -98,15 +102,19 @@ MapgenV5Params::MapgenV5Params(): void MapgenV5Params::readParams(const Settings *settings) { - settings->getFlagStrNoEx("mgv5_spflags", spflags, flagdesc_mapgen_v5); - settings->getFloatNoEx("mgv5_cave_width", cave_width); - settings->getS16NoEx("mgv5_large_cave_depth", large_cave_depth); - settings->getS16NoEx("mgv5_lava_depth", lava_depth); - settings->getS16NoEx("mgv5_cavern_limit", cavern_limit); - settings->getS16NoEx("mgv5_cavern_taper", cavern_taper); - settings->getFloatNoEx("mgv5_cavern_threshold", cavern_threshold); - settings->getS16NoEx("mgv5_dungeon_ymin", dungeon_ymin); - settings->getS16NoEx("mgv5_dungeon_ymax", dungeon_ymax); + settings->getFlagStrNoEx("mgv5_spflags", spflags, flagdesc_mapgen_v5); + settings->getFloatNoEx("mgv5_cave_width", cave_width); + settings->getS16NoEx("mgv5_large_cave_depth", large_cave_depth); + settings->getU16NoEx("mgv5_small_cave_num_min", small_cave_num_min); + settings->getU16NoEx("mgv5_small_cave_num_max", small_cave_num_max); + settings->getU16NoEx("mgv5_large_cave_num_min", large_cave_num_min); + settings->getU16NoEx("mgv5_large_cave_num_max", large_cave_num_max); + settings->getFloatNoEx("mgv5_large_cave_flooded", large_cave_flooded); + settings->getS16NoEx("mgv5_cavern_limit", cavern_limit); + settings->getS16NoEx("mgv5_cavern_taper", cavern_taper); + settings->getFloatNoEx("mgv5_cavern_threshold", cavern_threshold); + settings->getS16NoEx("mgv5_dungeon_ymin", dungeon_ymin); + settings->getS16NoEx("mgv5_dungeon_ymax", dungeon_ymax); settings->getNoiseParams("mgv5_np_filler_depth", np_filler_depth); settings->getNoiseParams("mgv5_np_factor", np_factor); @@ -121,15 +129,19 @@ void MapgenV5Params::readParams(const Settings *settings) void MapgenV5Params::writeParams(Settings *settings) const { - settings->setFlagStr("mgv5_spflags", spflags, flagdesc_mapgen_v5, U32_MAX); - settings->setFloat("mgv5_cave_width", cave_width); - settings->setS16("mgv5_large_cave_depth", large_cave_depth); - settings->setS16("mgv5_lava_depth", lava_depth); - settings->setS16("mgv5_cavern_limit", cavern_limit); - settings->setS16("mgv5_cavern_taper", cavern_taper); - settings->setFloat("mgv5_cavern_threshold", cavern_threshold); - settings->setS16("mgv5_dungeon_ymin", dungeon_ymin); - settings->setS16("mgv5_dungeon_ymax", dungeon_ymax); + settings->setFlagStr("mgv5_spflags", spflags, flagdesc_mapgen_v5); + settings->setFloat("mgv5_cave_width", cave_width); + settings->setS16("mgv5_large_cave_depth", large_cave_depth); + settings->setU16("mgv5_small_cave_num_min", small_cave_num_min); + settings->setU16("mgv5_small_cave_num_max", small_cave_num_max); + settings->setU16("mgv5_large_cave_num_min", large_cave_num_min); + settings->setU16("mgv5_large_cave_num_max", large_cave_num_max); + settings->setFloat("mgv5_large_cave_flooded", large_cave_flooded); + settings->setS16("mgv5_cavern_limit", cavern_limit); + settings->setS16("mgv5_cavern_taper", cavern_taper); + settings->setFloat("mgv5_cavern_threshold", cavern_threshold); + settings->setS16("mgv5_dungeon_ymin", dungeon_ymin); + settings->setS16("mgv5_dungeon_ymax", dungeon_ymax); settings->setNoiseParams("mgv5_np_filler_depth", np_filler_depth); settings->setNoiseParams("mgv5_np_factor", np_factor); @@ -142,6 +154,15 @@ void MapgenV5Params::writeParams(Settings *settings) const } +void MapgenV5Params::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mgv5_spflags", flagdesc_mapgen_v5, MGV5_CAVERNS); +} + + +///////////////////////////////////////////////////////////////// + + int MapgenV5::getSpawnLevelAtPoint(v2s16 p) { @@ -240,8 +261,7 @@ void MapgenV5::makeChunk(BlockMakeData *data) m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); // Generate dungeons and desert temples - if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin && - full_node_max.Y <= dungeon_ymax) + if (flags & MG_DUNGEONS) generateDungeons(stone_surface_max_y); // Generate the registered decorations diff --git a/src/mapgen/mapgen_v5.h b/src/mapgen/mapgen_v5.h index 1a3b6d3c3..17bc466f0 100644 --- a/src/mapgen/mapgen_v5.h +++ b/src/mapgen/mapgen_v5.h @@ -31,10 +31,13 @@ extern FlagDesc flagdesc_mapgen_v5[]; struct MapgenV5Params : public MapgenParams { - u32 spflags = MGV5_CAVERNS; float cave_width = 0.09f; s16 large_cave_depth = -256; - s16 lava_depth = -256; + u16 small_cave_num_min = 0; + u16 small_cave_num_max = 0; + u16 large_cave_num_min = 0; + u16 large_cave_num_max = 2; + float large_cave_flooded = 0.5f; s16 cavern_limit = -256; s16 cavern_taper = 256; float cavern_threshold = 0.7f; @@ -55,6 +58,7 @@ struct MapgenV5Params : public MapgenParams void readParams(const Settings *settings); void writeParams(Settings *settings) const; + void setDefaultSettings(Settings *settings); }; class MapgenV5 : public MapgenBasic @@ -70,10 +74,6 @@ public: int generateBaseTerrain(); private: - s16 large_cave_depth; - s16 dungeon_ymin; - s16 dungeon_ymax; - Noise *noise_factor; Noise *noise_height; Noise *noise_ground; diff --git a/src/mapgen/mapgen_v6.cpp b/src/mapgen/mapgen_v6.cpp index 4e876fc53..653adc8ec 100644 --- a/src/mapgen/mapgen_v6.cpp +++ b/src/mapgen/mapgen_v6.cpp @@ -190,7 +190,7 @@ void MapgenV6Params::readParams(const Settings *settings) void MapgenV6Params::writeParams(Settings *settings) const { - settings->setFlagStr("mgv6_spflags", spflags, flagdesc_mapgen_v6, U32_MAX); + settings->setFlagStr("mgv6_spflags", spflags, flagdesc_mapgen_v6); settings->setFloat("mgv6_freq_desert", freq_desert); settings->setFloat("mgv6_freq_beach", freq_beach); settings->setS16("mgv6_dungeon_ymin", dungeon_ymin); @@ -210,8 +210,16 @@ void MapgenV6Params::writeParams(Settings *settings) const } +void MapgenV6Params::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mgv6_spflags", flagdesc_mapgen_v6, MGV6_JUNGLES | + MGV6_SNOWBIOMES | MGV6_TREES | MGV6_BIOMEBLEND | MGV6_MUDFLOW); +} + + //////////////////////// Some helper functions for the map generator + // Returns Y one under area minimum if not found s16 MapgenV6::find_stone_level(v2s16 p2d) { diff --git a/src/mapgen/mapgen_v6.h b/src/mapgen/mapgen_v6.h index 7d5229559..d8cdcb26f 100644 --- a/src/mapgen/mapgen_v6.h +++ b/src/mapgen/mapgen_v6.h @@ -55,8 +55,6 @@ enum BiomeV6Type struct MapgenV6Params : public MapgenParams { - u32 spflags = MGV6_JUNGLES | MGV6_SNOWBIOMES | MGV6_TREES | - MGV6_BIOMEBLEND | MGV6_MUDFLOW; float freq_desert = 0.45f; float freq_beach = 0.15f; s16 dungeon_ymin = -31000; @@ -79,6 +77,7 @@ struct MapgenV6Params : public MapgenParams { void readParams(const Settings *settings); void writeParams(Settings *settings) const; + void setDefaultSettings(Settings *settings); }; diff --git a/src/mapgen/mapgen_v7.cpp b/src/mapgen/mapgen_v7.cpp index c9568760f..325c4957a 100644 --- a/src/mapgen/mapgen_v7.cpp +++ b/src/mapgen/mapgen_v7.cpp @@ -1,7 +1,7 @@ /* Minetest -Copyright (C) 2013-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net> -Copyright (C) 2014-2018 paramat +Copyright (C) 2013-2019 kwolekr, Ryan Kwolek <kwolekr@minetest.net> +Copyright (C) 2014-2019 paramat This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -55,26 +55,21 @@ FlagDesc flagdesc_mapgen_v7[] = { MapgenV7::MapgenV7(MapgenV7Params *params, EmergeManager *emerge) : MapgenBasic(MAPGEN_V7, params, emerge) { - spflags = params->spflags; - mount_zero_level = params->mount_zero_level; - float_mount_density = params->float_mount_density; - float_mount_exponent = params->float_mount_exponent; - floatland_level = params->floatland_level; - shadow_limit = params->shadow_limit; - - cave_width = params->cave_width; - large_cave_depth = params->large_cave_depth; - lava_depth = params->lava_depth; - cavern_limit = params->cavern_limit; - cavern_taper = params->cavern_taper; - cavern_threshold = params->cavern_threshold; - dungeon_ymin = params->dungeon_ymin; - dungeon_ymax = params->dungeon_ymax; - - // This is to avoid a divide-by-zero. - // Parameter will be saved to map_meta.txt in limited form. - params->float_mount_height = std::fmax(params->float_mount_height, 1.0f); - float_mount_height = params->float_mount_height; + spflags = params->spflags; + mount_zero_level = params->mount_zero_level; + + cave_width = params->cave_width; + large_cave_depth = params->large_cave_depth; + small_cave_num_min = params->small_cave_num_min; + small_cave_num_max = params->small_cave_num_max; + large_cave_num_min = params->large_cave_num_min; + large_cave_num_max = params->large_cave_num_max; + large_cave_flooded = params->large_cave_flooded; + cavern_limit = params->cavern_limit; + cavern_taper = params->cavern_taper; + cavern_threshold = params->cavern_threshold; + dungeon_ymin = params->dungeon_ymin; + dungeon_ymax = params->dungeon_ymax; // 2D noise noise_terrain_base = @@ -88,34 +83,29 @@ MapgenV7::MapgenV7(MapgenV7Params *params, EmergeManager *emerge) noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z); - if (spflags & MGV7_MOUNTAINS) + if (spflags & MGV7_MOUNTAINS) { + // 2D noise noise_mount_height = - new Noise(¶ms->np_mount_height, seed, csize.X, csize.Z); - - if (spflags & MGV7_FLOATLANDS) { - noise_floatland_base = - new Noise(¶ms->np_floatland_base, seed, csize.X, csize.Z); - noise_float_base_height = - new Noise(¶ms->np_float_base_height, seed, csize.X, csize.Z); + new Noise(¶ms->np_mount_height, seed, csize.X, csize.Z); + // 3D noise, 1 up, 1 down overgeneration + noise_mountain = + new Noise(¶ms->np_mountain, seed, csize.X, csize.Y + 2, csize.Z); } if (spflags & MGV7_RIDGES) { + // 2D noise noise_ridge_uwater = - new Noise(¶ms->np_ridge_uwater, seed, csize.X, csize.Z); - // 3D noise, 1 up, 1 down overgeneration + new Noise(¶ms->np_ridge_uwater, seed, csize.X, csize.Z); + // 3D noise, 1 up, 1 down overgeneration noise_ridge = - new Noise(¶ms->np_ridge, seed, csize.X, csize.Y + 2, csize.Z); + new Noise(¶ms->np_ridge, seed, csize.X, csize.Y + 2, csize.Z); } - // 3D noise, 1 up, 1 down overgeneration - if ((spflags & MGV7_MOUNTAINS) || (spflags & MGV7_FLOATLANDS)) - noise_mountain = - 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; + // 3D noise MapgenBasic::np_dungeons = params->np_dungeons; } @@ -128,21 +118,15 @@ MapgenV7::~MapgenV7() delete noise_height_select; delete noise_filler_depth; - if (spflags & MGV7_MOUNTAINS) + if (spflags & MGV7_MOUNTAINS) { delete noise_mount_height; - - if (spflags & MGV7_FLOATLANDS) { - delete noise_floatland_base; - delete noise_float_base_height; + delete noise_mountain; } if (spflags & MGV7_RIDGES) { delete noise_ridge_uwater; delete noise_ridge; } - - if ((spflags & MGV7_MOUNTAINS) || (spflags & MGV7_FLOATLANDS)) - delete noise_mountain; } @@ -154,8 +138,6 @@ MapgenV7Params::MapgenV7Params(): np_filler_depth (0.0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0), np_mount_height (256.0, 112.0, v3f(1000, 1000, 1000), 72449, 3, 0.6, 2.0), np_ridge_uwater (0.0, 1.0, v3f(1000, 1000, 1000), 85039, 5, 0.6, 2.0), - np_floatland_base (-0.6, 1.5, v3f(600, 600, 600), 114, 5, 0.6, 2.0), - np_float_base_height (48.0, 24.0, v3f(300, 300, 300), 907, 4, 0.7, 2.0), np_mountain (-0.6, 1.0, v3f(250, 350, 250), 5333, 5, 0.63, 2.0), 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), @@ -172,69 +154,70 @@ void MapgenV7Params::readParams(const Settings *settings) settings->getS16NoEx("mgv7_mount_zero_level", mount_zero_level); settings->getFloatNoEx("mgv7_cave_width", cave_width); settings->getS16NoEx("mgv7_large_cave_depth", large_cave_depth); - settings->getS16NoEx("mgv7_lava_depth", lava_depth); - settings->getFloatNoEx("mgv7_float_mount_density", float_mount_density); - settings->getFloatNoEx("mgv7_float_mount_height", float_mount_height); - settings->getFloatNoEx("mgv7_float_mount_exponent", float_mount_exponent); - settings->getS16NoEx("mgv7_floatland_level", floatland_level); - settings->getS16NoEx("mgv7_shadow_limit", shadow_limit); + settings->getU16NoEx("mgv7_small_cave_num_min", small_cave_num_min); + settings->getU16NoEx("mgv7_small_cave_num_max", small_cave_num_max); + settings->getU16NoEx("mgv7_large_cave_num_min", large_cave_num_min); + settings->getU16NoEx("mgv7_large_cave_num_max", large_cave_num_max); + settings->getFloatNoEx("mgv7_large_cave_flooded", large_cave_flooded); settings->getS16NoEx("mgv7_cavern_limit", cavern_limit); settings->getS16NoEx("mgv7_cavern_taper", cavern_taper); settings->getFloatNoEx("mgv7_cavern_threshold", cavern_threshold); settings->getS16NoEx("mgv7_dungeon_ymin", dungeon_ymin); settings->getS16NoEx("mgv7_dungeon_ymax", dungeon_ymax); - settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base); - settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt); - settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist); - settings->getNoiseParams("mgv7_np_height_select", np_height_select); - settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth); - settings->getNoiseParams("mgv7_np_mount_height", np_mount_height); - settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater); - settings->getNoiseParams("mgv7_np_floatland_base", np_floatland_base); - settings->getNoiseParams("mgv7_np_float_base_height", np_float_base_height); - settings->getNoiseParams("mgv7_np_mountain", np_mountain); - settings->getNoiseParams("mgv7_np_ridge", np_ridge); - 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); + settings->getNoiseParams("mgv7_np_terrain_base", np_terrain_base); + settings->getNoiseParams("mgv7_np_terrain_alt", np_terrain_alt); + settings->getNoiseParams("mgv7_np_terrain_persist", np_terrain_persist); + settings->getNoiseParams("mgv7_np_height_select", np_height_select); + settings->getNoiseParams("mgv7_np_filler_depth", np_filler_depth); + settings->getNoiseParams("mgv7_np_mount_height", np_mount_height); + settings->getNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater); + settings->getNoiseParams("mgv7_np_mountain", np_mountain); + settings->getNoiseParams("mgv7_np_ridge", np_ridge); + 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); } void MapgenV7Params::writeParams(Settings *settings) const { - settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7, U32_MAX); - settings->setS16("mgv7_mount_zero_level", mount_zero_level); - settings->setFloat("mgv7_cave_width", cave_width); - settings->setS16("mgv7_large_cave_depth", large_cave_depth); - settings->setS16("mgv7_lava_depth", lava_depth); - settings->setFloat("mgv7_float_mount_density", float_mount_density); - settings->setFloat("mgv7_float_mount_height", float_mount_height); - settings->setFloat("mgv7_float_mount_exponent", float_mount_exponent); - settings->setS16("mgv7_floatland_level", floatland_level); - settings->setS16("mgv7_shadow_limit", shadow_limit); - settings->setS16("mgv7_cavern_limit", cavern_limit); - settings->setS16("mgv7_cavern_taper", cavern_taper); - settings->setFloat("mgv7_cavern_threshold", cavern_threshold); - settings->setS16("mgv7_dungeon_ymin", dungeon_ymin); - settings->setS16("mgv7_dungeon_ymax", dungeon_ymax); - - settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base); - settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt); - settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist); - settings->setNoiseParams("mgv7_np_height_select", np_height_select); - settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth); - settings->setNoiseParams("mgv7_np_mount_height", np_mount_height); - settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater); - settings->setNoiseParams("mgv7_np_floatland_base", np_floatland_base); - settings->setNoiseParams("mgv7_np_float_base_height", np_float_base_height); - settings->setNoiseParams("mgv7_np_mountain", np_mountain); - settings->setNoiseParams("mgv7_np_ridge", np_ridge); - 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); + settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7); + settings->setS16("mgv7_mount_zero_level", mount_zero_level); + settings->setFloat("mgv7_cave_width", cave_width); + settings->setS16("mgv7_large_cave_depth", large_cave_depth); + settings->setU16("mgv7_small_cave_num_min", small_cave_num_min); + settings->setU16("mgv7_small_cave_num_max", small_cave_num_max); + settings->setU16("mgv7_large_cave_num_min", large_cave_num_min); + settings->setU16("mgv7_large_cave_num_max", large_cave_num_max); + settings->setFloat("mgv7_large_cave_flooded", large_cave_flooded); + settings->setS16("mgv7_cavern_limit", cavern_limit); + settings->setS16("mgv7_cavern_taper", cavern_taper); + settings->setFloat("mgv7_cavern_threshold", cavern_threshold); + settings->setS16("mgv7_dungeon_ymin", dungeon_ymin); + settings->setS16("mgv7_dungeon_ymax", dungeon_ymax); + + settings->setNoiseParams("mgv7_np_terrain_base", np_terrain_base); + settings->setNoiseParams("mgv7_np_terrain_alt", np_terrain_alt); + settings->setNoiseParams("mgv7_np_terrain_persist", np_terrain_persist); + settings->setNoiseParams("mgv7_np_height_select", np_height_select); + settings->setNoiseParams("mgv7_np_filler_depth", np_filler_depth); + settings->setNoiseParams("mgv7_np_mount_height", np_mount_height); + settings->setNoiseParams("mgv7_np_ridge_uwater", np_ridge_uwater); + settings->setNoiseParams("mgv7_np_mountain", np_mountain); + settings->setNoiseParams("mgv7_np_ridge", np_ridge); + 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); +} + + +void MapgenV7Params::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mgv7_spflags", flagdesc_mapgen_v7, + MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS); } @@ -360,8 +343,7 @@ void MapgenV7::makeChunk(BlockMakeData *data) m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); // Generate dungeons - if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin && - full_node_max.Y <= dungeon_ymax) + if (flags & MG_DUNGEONS) generateDungeons(stone_surface_max_y); // Generate the registered decorations @@ -375,10 +357,9 @@ void MapgenV7::makeChunk(BlockMakeData *data) // Update liquids updateLiquid(&data->transforming_liquid, full_node_min, full_node_max); - // Calculate lighting. - // Limit floatland shadow. - bool propagate_shadow = !((spflags & MGV7_FLOATLANDS) && - node_min.Y <= shadow_limit && node_max.Y >= shadow_limit); + // Calculate lighting + // TODO disable in and just below floatlands + bool propagate_shadow = true; if (flags & MG_LIGHT) calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0), @@ -447,53 +428,6 @@ bool MapgenV7::getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y) } -bool MapgenV7::getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y) -{ - // Make rim 2 nodes thick to match floatland base terrain - float density_gradient = (y >= floatland_level) ? - -std::pow((float)(y - floatland_level) / float_mount_height, - float_mount_exponent) : - -std::pow((float)(floatland_level - 1 - y) / float_mount_height, - float_mount_exponent); - - float floatn = noise_mountain->result[idx_xyz] + float_mount_density; - - return floatn + density_gradient >= 0.0f; -} - - -void MapgenV7::floatBaseExtentFromMap(s16 *float_base_min, s16 *float_base_max, - int idx_xz) -{ - // '+1' to avoid a layer of stone at y = MAX_MAP_GENERATION_LIMIT - s16 base_min = MAX_MAP_GENERATION_LIMIT + 1; - s16 base_max = MAX_MAP_GENERATION_LIMIT; - - float n_base = noise_floatland_base->result[idx_xz]; - if (n_base > 0.0f) { - float n_base_height = - std::fmax(noise_float_base_height->result[idx_xz], 1.0f); - float amp = n_base * n_base_height; - float ridge = n_base_height / 3.0f; - base_min = floatland_level - amp / 1.5f; - - if (amp > ridge * 2.0f) { - // Lake bed - base_max = floatland_level - (amp - ridge * 2.0f) / 2.0f; - } else { - // Hills and ridges - float diff = std::fabs(amp - ridge) / ridge; - // Smooth ridges using the 'smoothstep function' - float smooth_diff = diff * diff * (3.0f - 2.0f * diff); - base_max = floatland_level + ridge - smooth_diff * ridge; - } - } - - *float_base_min = base_min; - *float_base_max = base_max; -} - - int MapgenV7::generateTerrain() { MapNode n_air(CONTENT_AIR); @@ -508,17 +442,9 @@ int MapgenV7::generateTerrain() noise_terrain_alt->perlinMap2D(node_min.X, node_min.Z, persistmap); noise_height_select->perlinMap2D(node_min.X, node_min.Z); - if ((spflags & MGV7_MOUNTAINS) || (spflags & MGV7_FLOATLANDS)) { - noise_mountain->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z); - } - if (spflags & MGV7_MOUNTAINS) { noise_mount_height->perlinMap2D(node_min.X, node_min.Z); - } - - if (spflags & MGV7_FLOATLANDS) { - noise_floatland_base->perlinMap2D(node_min.X, node_min.Z); - noise_float_base_height->perlinMap2D(node_min.X, node_min.Z); + noise_mountain->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z); } //// Place nodes @@ -532,13 +458,6 @@ int MapgenV7::generateTerrain() if (surface_y > stone_surface_max_y) stone_surface_max_y = surface_y; - // Get extent of floatland base terrain - // '+1' to avoid a layer of stone at y = MAX_MAP_GENERATION_LIMIT - s16 float_base_min = MAX_MAP_GENERATION_LIMIT + 1; - s16 float_base_max = MAX_MAP_GENERATION_LIMIT; - if (spflags & MGV7_FLOATLANDS) - floatBaseExtentFromMap(&float_base_min, &float_base_max, index2d); - u32 vi = vm->m_area.index(x, node_min.Y - 1, z); u32 index3d = (z - node_min.Z) * zstride_1u1d + (x - node_min.X); @@ -556,16 +475,8 @@ int MapgenV7::generateTerrain() vm->m_data[vi] = n_stone; // Mountain terrain if (y > stone_surface_max_y) stone_surface_max_y = y; - } else if ((spflags & MGV7_FLOATLANDS) && - ((y >= float_base_min && y <= float_base_max) || - getFloatlandMountainFromMap(index3d, index2d, y))) { - vm->m_data[vi] = n_stone; // Floatland terrain - stone_surface_max_y = node_max.Y; } else if (y <= water_level) { - vm->m_data[vi] = n_water; // Ground level water - } else if ((spflags & MGV7_FLOATLANDS) && - (y >= float_base_max && y <= floatland_level)) { - vm->m_data[vi] = n_water; // Floatland water + vm->m_data[vi] = n_water; } else { vm->m_data[vi] = n_air; } @@ -578,8 +489,8 @@ int MapgenV7::generateTerrain() void MapgenV7::generateRidgeTerrain() { - if (node_max.Y < water_level - 16 || - ((spflags & MGV7_FLOATLANDS) && node_max.Y > shadow_limit)) + // TODO disable river canyons in floatlands + if (node_max.Y < water_level - 16) return; noise_ridge->perlinMap3D(node_min.X, node_min.Y - 1, node_min.Z); diff --git a/src/mapgen/mapgen_v7.h b/src/mapgen/mapgen_v7.h index 50039b16a..0605c5c97 100644 --- a/src/mapgen/mapgen_v7.h +++ b/src/mapgen/mapgen_v7.h @@ -35,17 +35,15 @@ extern FlagDesc flagdesc_mapgen_v7[]; struct MapgenV7Params : public MapgenParams { - u32 spflags = MGV7_MOUNTAINS | MGV7_RIDGES | MGV7_CAVERNS; s16 mount_zero_level = 0; - float float_mount_density = 0.6f; - float float_mount_height = 128.0f; - float float_mount_exponent = 0.75f; - s16 floatland_level = 1280; - s16 shadow_limit = 1024; float cave_width = 0.09f; s16 large_cave_depth = -33; - s16 lava_depth = -256; + u16 small_cave_num_min = 0; + u16 small_cave_num_max = 0; + u16 large_cave_num_min = 0; + u16 large_cave_num_max = 2; + float large_cave_flooded = 0.5f; s16 cavern_limit = -256; s16 cavern_taper = 256; float cavern_threshold = 0.7f; @@ -59,8 +57,6 @@ struct MapgenV7Params : public MapgenParams { NoiseParams np_filler_depth; NoiseParams np_mount_height; NoiseParams np_ridge_uwater; - NoiseParams np_floatland_base; - NoiseParams np_float_base_height; NoiseParams np_mountain; NoiseParams np_ridge; NoiseParams np_cavern; @@ -73,6 +69,7 @@ struct MapgenV7Params : public MapgenParams { void readParams(const Settings *settings); void writeParams(Settings *settings) const; + void setDefaultSettings(Settings *settings); }; @@ -90,23 +87,12 @@ public: float baseTerrainLevelFromMap(int index); bool getMountainTerrainAtPoint(s16 x, s16 y, s16 z); bool getMountainTerrainFromMap(int idx_xyz, int idx_xz, s16 y); - bool getFloatlandMountainFromMap(int idx_xyz, int idx_xz, s16 y); - void floatBaseExtentFromMap(s16 *float_base_min, s16 *float_base_max, int idx_xz); int generateTerrain(); void generateRidgeTerrain(); private: s16 mount_zero_level; - float float_mount_density; - float float_mount_height; - float float_mount_exponent; - s16 floatland_level; - s16 shadow_limit; - - s16 large_cave_depth; - s16 dungeon_ymin; - s16 dungeon_ymax; Noise *noise_terrain_base; Noise *noise_terrain_alt; @@ -114,8 +100,6 @@ private: Noise *noise_height_select; Noise *noise_mount_height; Noise *noise_ridge_uwater; - Noise *noise_floatland_base; - Noise *noise_float_base_height; Noise *noise_mountain; Noise *noise_ridge; }; diff --git a/src/mapgen/mapgen_valleys.cpp b/src/mapgen/mapgen_valleys.cpp index d0b36f29b..ff908b7bb 100644 --- a/src/mapgen/mapgen_valleys.cpp +++ b/src/mapgen/mapgen_valleys.cpp @@ -67,7 +67,11 @@ MapgenValleys::MapgenValleys(MapgenValleysParams *params, EmergeManager *emerge) cave_width = params->cave_width; large_cave_depth = params->large_cave_depth; - lava_depth = params->lava_depth; + small_cave_num_min = params->small_cave_num_min; + small_cave_num_max = params->small_cave_num_max; + large_cave_num_min = params->large_cave_num_min; + large_cave_num_max = params->large_cave_num_max; + large_cave_flooded = params->large_cave_flooded; cavern_limit = params->cavern_limit; cavern_taper = params->cavern_taper; cavern_threshold = params->cavern_threshold; @@ -124,18 +128,22 @@ MapgenValleysParams::MapgenValleysParams(): void MapgenValleysParams::readParams(const Settings *settings) { - settings->getFlagStrNoEx("mgvalleys_spflags", spflags, flagdesc_mapgen_valleys); - settings->getU16NoEx("mgvalleys_altitude_chill", altitude_chill); - settings->getS16NoEx("mgvalleys_large_cave_depth", large_cave_depth); - settings->getS16NoEx("mgvalleys_lava_depth", lava_depth); - settings->getU16NoEx("mgvalleys_river_depth", river_depth); - settings->getU16NoEx("mgvalleys_river_size", river_size); - settings->getFloatNoEx("mgvalleys_cave_width", cave_width); - settings->getS16NoEx("mgvalleys_cavern_limit", cavern_limit); - settings->getS16NoEx("mgvalleys_cavern_taper", cavern_taper); - settings->getFloatNoEx("mgvalleys_cavern_threshold", cavern_threshold); - settings->getS16NoEx("mgvalleys_dungeon_ymin", dungeon_ymin); - settings->getS16NoEx("mgvalleys_dungeon_ymax", dungeon_ymax); + settings->getFlagStrNoEx("mgvalleys_spflags", spflags, flagdesc_mapgen_valleys); + settings->getU16NoEx("mgvalleys_altitude_chill", altitude_chill); + settings->getS16NoEx("mgvalleys_large_cave_depth", large_cave_depth); + settings->getU16NoEx("mgvalleys_small_cave_num_min", small_cave_num_min); + settings->getU16NoEx("mgvalleys_small_cave_num_max", small_cave_num_max); + settings->getU16NoEx("mgvalleys_large_cave_num_min", large_cave_num_min); + settings->getU16NoEx("mgvalleys_large_cave_num_max", large_cave_num_max); + settings->getFloatNoEx("mgvalleys_large_cave_flooded", large_cave_flooded); + settings->getU16NoEx("mgvalleys_river_depth", river_depth); + settings->getU16NoEx("mgvalleys_river_size", river_size); + settings->getFloatNoEx("mgvalleys_cave_width", cave_width); + settings->getS16NoEx("mgvalleys_cavern_limit", cavern_limit); + settings->getS16NoEx("mgvalleys_cavern_taper", cavern_taper); + settings->getFloatNoEx("mgvalleys_cavern_threshold", cavern_threshold); + settings->getS16NoEx("mgvalleys_dungeon_ymin", dungeon_ymin); + settings->getS16NoEx("mgvalleys_dungeon_ymax", dungeon_ymax); settings->getNoiseParams("mgvalleys_np_filler_depth", np_filler_depth); settings->getNoiseParams("mgvalleys_np_inter_valley_fill", np_inter_valley_fill); @@ -154,18 +162,22 @@ void MapgenValleysParams::readParams(const Settings *settings) void MapgenValleysParams::writeParams(Settings *settings) const { - settings->setFlagStr("mgvalleys_spflags", spflags, flagdesc_mapgen_valleys, U32_MAX); - settings->setU16("mgvalleys_altitude_chill", altitude_chill); - settings->setS16("mgvalleys_large_cave_depth", large_cave_depth); - settings->setS16("mgvalleys_lava_depth", lava_depth); - settings->setU16("mgvalleys_river_depth", river_depth); - settings->setU16("mgvalleys_river_size", river_size); - settings->setFloat("mgvalleys_cave_width", cave_width); - settings->setS16("mgvalleys_cavern_limit", cavern_limit); - settings->setS16("mgvalleys_cavern_taper", cavern_taper); - settings->setFloat("mgvalleys_cavern_threshold", cavern_threshold); - settings->setS16("mgvalleys_dungeon_ymin", dungeon_ymin); - settings->setS16("mgvalleys_dungeon_ymax", dungeon_ymax); + settings->setFlagStr("mgvalleys_spflags", spflags, flagdesc_mapgen_valleys); + settings->setU16("mgvalleys_altitude_chill", altitude_chill); + settings->setS16("mgvalleys_large_cave_depth", large_cave_depth); + settings->setU16("mgvalleys_small_cave_num_min", small_cave_num_min); + settings->setU16("mgvalleys_small_cave_num_max", small_cave_num_max); + settings->setU16("mgvalleys_large_cave_num_min", large_cave_num_min); + settings->setU16("mgvalleys_large_cave_num_max", large_cave_num_max); + settings->setFloat("mgvalleys_large_cave_flooded", large_cave_flooded); + settings->setU16("mgvalleys_river_depth", river_depth); + settings->setU16("mgvalleys_river_size", river_size); + settings->setFloat("mgvalleys_cave_width", cave_width); + settings->setS16("mgvalleys_cavern_limit", cavern_limit); + settings->setS16("mgvalleys_cavern_taper", cavern_taper); + settings->setFloat("mgvalleys_cavern_threshold", cavern_threshold); + settings->setS16("mgvalleys_dungeon_ymin", dungeon_ymin); + settings->setS16("mgvalleys_dungeon_ymax", dungeon_ymax); settings->setNoiseParams("mgvalleys_np_filler_depth", np_filler_depth); settings->setNoiseParams("mgvalleys_np_inter_valley_fill", np_inter_valley_fill); @@ -182,6 +194,17 @@ void MapgenValleysParams::writeParams(Settings *settings) const } +void MapgenValleysParams::setDefaultSettings(Settings *settings) +{ + settings->setDefault("mgvalleys_spflags", flagdesc_mapgen_valleys, + MGVALLEYS_ALT_CHILL | MGVALLEYS_HUMID_RIVERS | + MGVALLEYS_VARY_RIVER_DEPTH | MGVALLEYS_ALT_DRY); +} + + +///////////////////////////////////////////////////////////////// + + void MapgenValleys::makeChunk(BlockMakeData *data) { // Pre-conditions @@ -248,8 +271,7 @@ void MapgenValleys::makeChunk(BlockMakeData *data) m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max); // Dungeon creation - if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin && - full_node_max.Y <= dungeon_ymax) + if (flags & MG_DUNGEONS) generateDungeons(stone_surface_max_y); // Generate the registered decorations @@ -368,7 +390,7 @@ int MapgenValleys::generateTerrain() // Rivers are placed where 'river' is negative if (river < 0.0f) { - // Use the the function -sqrt(1-x^2) which models a circle + // Use the function -sqrt(1-x^2) which models a circle float tr = river / river_size_factor + 1.0f; float depth = (river_depth_bed * std::sqrt(std::fmax(0.0f, 1.0f - tr * tr))); diff --git a/src/mapgen/mapgen_valleys.h b/src/mapgen/mapgen_valleys.h index ab80dc5c9..1aec68842 100644 --- a/src/mapgen/mapgen_valleys.h +++ b/src/mapgen/mapgen_valleys.h @@ -41,15 +41,17 @@ extern FlagDesc flagdesc_mapgen_valleys[]; struct MapgenValleysParams : public MapgenParams { - u32 spflags = MGVALLEYS_ALT_CHILL | MGVALLEYS_HUMID_RIVERS | - MGVALLEYS_VARY_RIVER_DEPTH | MGVALLEYS_ALT_DRY; u16 altitude_chill = 90; u16 river_depth = 4; u16 river_size = 5; float cave_width = 0.09f; s16 large_cave_depth = -33; - s16 lava_depth = 1; + u16 small_cave_num_min = 0; + u16 small_cave_num_max = 0; + u16 large_cave_num_min = 0; + u16 large_cave_num_max = 2; + float large_cave_flooded = 0.5f; s16 cavern_limit = -256; s16 cavern_taper = 192; float cavern_threshold = 0.6f; @@ -74,6 +76,7 @@ struct MapgenValleysParams : public MapgenParams { void readParams(const Settings *settings); void writeParams(Settings *settings) const; + void setDefaultSettings(Settings *settings); }; @@ -96,10 +99,6 @@ private: float river_depth_bed; float river_size_factor; - s16 large_cave_depth; - s16 dungeon_ymin; - s16 dungeon_ymax; - Noise *noise_inter_valley_fill; Noise *noise_inter_valley_slope; Noise *noise_rivers; |