aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen_v7.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapgen_v7.cpp')
-rw-r--r--src/mapgen_v7.cpp116
1 files changed, 75 insertions, 41 deletions
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index 6d5c04900..77e25a672 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -38,33 +38,16 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "mapgen_v7.h"
-/////////////////// Mapgen V7 perlin noise default values
-NoiseParams nparams_v7_def_terrain_base =
- {4, 70, v3f(300, 300, 300), 82341, 6, 0.7};
-NoiseParams nparams_v7_def_terrain_alt =
- {4, 25, v3f(600, 600, 600), 5934, 5, 0.6};
-NoiseParams nparams_v7_def_terrain_persist =
- {0.6, 0.1, v3f(500, 500, 500), 539, 3, 0.6};
-NoiseParams nparams_v7_def_height_select =
- {-0.5, 1, v3f(250, 250, 250), 4213, 5, 0.69};
-
-NoiseParams nparams_v7_def_filler_depth =
- {0, 1.2, v3f(150, 150, 150), 261, 4, 0.7};
-
-NoiseParams nparams_v7_def_mount_height =
- {100, 30, v3f(500, 500, 500), 72449, 4, 0.6};
-NoiseParams nparams_v7_def_ridge_uwater =
- {0, 1, v3f(500, 500, 500), 85039, 4, 0.6};
-NoiseParams nparams_v7_def_mountain =
- {0, 1, v3f(250, 350, 250), 5333, 5, 0.68};
-NoiseParams nparams_v7_def_ridge =
- {0, 1, v3f(100, 100, 100), 6467, 4, 0.75};
-
+FlagDesc flagdesc_mapgen_v7[] = {
+ {"v7_mountains", MGV7_MOUNTAINS},
+ {"v7_ridges", MGV7_RIDGES},
+ {NULL, 0}
+};
///////////////////////////////////////////////////////////////////////////////
-MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge) {
+MapgenV7::MapgenV7(int mapgenid, MapgenParams *params, EmergeManager *emerge) {
this->generating = false;
this->id = mapgenid;
this->emerge = emerge;
@@ -86,19 +69,21 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
this->heightmap = new s16[csize.X * csize.Z];
this->ridge_heightmap = new s16[csize.X * csize.Z];
+ MapgenV7Params *sp = (MapgenV7Params *)params->sparams;
+
// Terrain noise
- noise_terrain_base = new Noise(&params->np_terrain_base, seed, csize.X, csize.Z);
- noise_terrain_alt = new Noise(&params->np_terrain_alt, seed, csize.X, csize.Z);
- noise_terrain_persist = new Noise(&params->np_terrain_persist, seed, csize.X, csize.Z);
- noise_height_select = new Noise(&params->np_height_select, seed, csize.X, csize.Z);
- noise_filler_depth = new Noise(&params->np_filler_depth, seed, csize.X, csize.Z);
- noise_mount_height = new Noise(&params->np_mount_height, seed, csize.X, csize.Z);
- noise_ridge_uwater = new Noise(&params->np_ridge_uwater, seed, csize.X, csize.Z);
-
+ noise_terrain_base = new Noise(&sp->np_terrain_base, seed, csize.X, csize.Z);
+ noise_terrain_alt = new Noise(&sp->np_terrain_alt, seed, csize.X, csize.Z);
+ noise_terrain_persist = new Noise(&sp->np_terrain_persist, seed, csize.X, csize.Z);
+ noise_height_select = new Noise(&sp->np_height_select, seed, csize.X, csize.Z);
+ noise_filler_depth = new Noise(&sp->np_filler_depth, seed, csize.X, csize.Z);
+ noise_mount_height = new Noise(&sp->np_mount_height, seed, csize.X, csize.Z);
+ noise_ridge_uwater = new Noise(&sp->np_ridge_uwater, seed, csize.X, csize.Z);
+
// 3d terrain noise
- noise_mountain = new Noise(&params->np_mountain, seed, csize.X, csize.Y, csize.Z);
- noise_ridge = new Noise(&params->np_ridge, seed, csize.X, csize.Y, csize.Z);
-
+ noise_mountain = new Noise(&sp->np_mountain, seed, csize.X, csize.Y, csize.Z);
+ noise_ridge = new Noise(&sp->np_ridge, seed, csize.X, csize.Y, csize.Z);
+
// Biome noise
noise_heat = new Noise(bmgr->np_heat, seed, csize.X, csize.Z);
noise_humidity = new Noise(bmgr->np_humidity, seed, csize.X, csize.Z);
@@ -125,6 +110,54 @@ MapgenV7::~MapgenV7() {
}
+MapgenV7Params::MapgenV7Params() {
+ spflags = MGV7_MOUNTAINS | MGV7_RIDGES;
+
+ np_terrain_base = NoiseParams(4, 70, v3f(300, 300, 300), 82341, 6, 0.7);
+ np_terrain_alt = NoiseParams(4, 25, v3f(600, 600, 600), 5934, 5, 0.6);
+ np_terrain_persist = NoiseParams(0.6, 0.1, v3f(500, 500, 500), 539, 3, 0.6);
+ np_height_select = NoiseParams(-0.5, 1, v3f(250, 250, 250), 4213, 5, 0.69);
+ np_filler_depth = NoiseParams(0, 1.2, v3f(150, 150, 150), 261, 4, 0.7);
+ np_mount_height = NoiseParams(100, 30, v3f(500, 500, 500), 72449, 4, 0.6);
+ np_ridge_uwater = NoiseParams(0, 1, v3f(500, 500, 500), 85039, 4, 0.6);
+ np_mountain = NoiseParams(0, 1, v3f(250, 350, 250), 5333, 5, 0.68);
+ np_ridge = NoiseParams(0, 1, v3f(100, 100, 100), 6467, 4, 0.75);
+}
+
+
+void MapgenV7Params::readParams(Settings *settings) {
+ settings->tryGetFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7);
+
+ 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);
+}
+
+
+void MapgenV7Params::writeParams(Settings *settings) {
+ settings->setFlagStr("mgv7_spflags", spflags, flagdesc_mapgen_v7);
+
+ 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);
+}
+
+
+///////////////////////////////////////
+
+
int MapgenV7::getGroundLevelAtPoint(v2s16 p) {
// Base terrain calculation
s16 y = baseTerrainLevelAtPoint(p.X, p.Y);
@@ -262,13 +295,13 @@ void MapgenV7::calculateNoise() {
noise_filler_depth->perlinMap2D(x, z);
- if (flags & MGV7_MOUNTAINS) {
+ if (spflags & MGV7_MOUNTAINS) {
noise_mountain->perlinMap3D(x, y, z);
noise_mount_height->perlinMap2D(x, z);
noise_mount_height->transformNoiseMap();
}
- if (flags & MGV7_RIDGES) {
+ if (spflags & MGV7_RIDGES) {
noise_ridge->perlinMap3D(x, y, z);
noise_ridge_uwater->perlinMap2D(x, z);
}
@@ -375,10 +408,10 @@ void MapgenV7::carveRivers() {
int MapgenV7::generateTerrain() {
int ymax = generateBaseTerrain();
- if (flags & MGV7_MOUNTAINS)
+ if (spflags & MGV7_MOUNTAINS)
generateMountainTerrain();
- if (flags & MGV7_RIDGES)
+ if (spflags & MGV7_RIDGES)
generateRidgeTerrain();
return ymax;
@@ -695,14 +728,15 @@ void MapgenV7::addTopNodes() {
#endif
-#include "mapgen_v6.h"
+NoiseParams nparams_v7_def_cave(6, 6.0, v3f(250.0, 250.0, 250.0), 34329, 3, 0.50);
+
void MapgenV7::generateCaves(int max_stone_y) {
PseudoRandom ps(blockseed + 21343);
int volume_nodes = (node_max.X - node_min.X + 1) *
(node_max.Y - node_min.Y + 1) *
(node_max.Z - node_min.Z + 1);
- float cave_amount = NoisePerlin2D(&nparams_v6_def_cave,
+ float cave_amount = NoisePerlin2D(&nparams_v7_def_cave,
node_min.X, node_min.Y, seed);
u32 caves_count = MYMAX(0.0, cave_amount) * volume_nodes / 250000;
@@ -715,5 +749,5 @@ void MapgenV7::generateCaves(int max_stone_y) {
for (u32 i = 0; i < bruises_count; i++) {
CaveV7 cave(this, &ps, true);
cave.makeCave(node_min, node_max, max_stone_y);
- }
+ }
}