#include "dungeongen.h"
#include "cavegen.h"
#include "treegen.h"
-#include "biome.h"
+#include "mg_biome.h"
+#include "mg_ore.h"
+#include "mg_decoration.h"
#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[] = {
+ {"mountains", MGV7_MOUNTAINS},
+ {"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;
this->bmgr = emerge->biomedef;
- this->seed = (int)params->seed;
+ this->seed = (int)params->seed;
this->water_level = params->water_level;
- this->flags = params->flags | MGV7_MOUNTAINS | MGV7_RIDGES;
+ this->flags = params->flags;
+ this->gennotify = emerge->gennotify;
this->csize = v3s16(1, 1, 1) * params->chunksize * MAP_BLOCKSIZE;
- // amount of elements to skip for the next index
- // for noise/height/biome maps (not vmanip)
+ //// amount of elements to skip for the next index
+ //// for noise/height/biome maps (not vmanip)
this->ystride = csize.X;
this->zstride = csize.X * csize.Y;
this->heightmap = new s16[csize.X * csize.Z];
this->ridge_heightmap = new s16[csize.X * csize.Z];
- // Terrain noise
- noise_terrain_base = new Noise(¶ms->np_terrain_base, seed, csize.X, csize.Z);
- noise_terrain_alt = new Noise(¶ms->np_terrain_alt, seed, csize.X, csize.Z);
- noise_terrain_persist = new Noise(¶ms->np_terrain_persist, seed, csize.X, csize.Z);
- noise_height_select = new Noise(¶ms->np_height_select, seed, csize.X, csize.Z);
- noise_filler_depth = new Noise(¶ms->np_filler_depth, seed, csize.X, csize.Z);
- noise_mount_height = new Noise(¶ms->np_mount_height, seed, csize.X, csize.Z);
- noise_ridge_uwater = new Noise(¶ms->np_ridge_uwater, seed, csize.X, csize.Z);
-
- // 3d terrain noise
- noise_mountain = new Noise(¶ms->np_mountain, seed, csize.X, csize.Y, csize.Z);
- noise_ridge = new Noise(¶ms->np_ridge, seed, csize.X, csize.Y, csize.Z);
-
- // Biome noise
+ MapgenV7Params *sp = (MapgenV7Params *)params->sparams;
+
+ //// Terrain noise
+ 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(&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);
+ noise_humidity = new Noise(bmgr->np_humidity, seed, csize.X, csize.Z);
+
+ //// Resolve nodes to be used
+ INodeDefManager *ndef = emerge->ndef;
+
+ c_stone = ndef->getId("mapgen_stone");
+ c_dirt = ndef->getId("mapgen_dirt");
+ c_dirt_with_grass = ndef->getId("mapgen_dirt_with_grass");
+ c_sand = ndef->getId("mapgen_sand");
+ c_water_source = ndef->getId("mapgen_water_source");
+ c_lava_source = ndef->getId("mapgen_lava_source");
+ c_ice = ndef->getId("default:ice");
+ if (c_ice == CONTENT_IGNORE)
+ c_ice = CONTENT_AIR;
}
}
+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->getFlagStrNoEx("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, (u32)-1);
+
+ 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);
blockseed = emerge->getBlockSeed(full_node_min); //////use getBlockSeed2()!
- c_stone = ndef->getId("mapgen_stone");
- c_dirt = ndef->getId("mapgen_dirt");
- c_dirt_with_grass = ndef->getId("mapgen_dirt_with_grass");
- c_sand = ndef->getId("mapgen_sand");
- c_water_source = ndef->getId("mapgen_water_source");
- c_lava_source = ndef->getId("mapgen_lava_source");
- c_ice = ndef->getId("default:ice");
- if (c_ice == CONTENT_IGNORE)
- c_ice = CONTENT_AIR;
-
// Make some noise
calculateNoise();
generateCaves(stone_surface_max_y);
if (flags & MG_DUNGEONS) {
- DungeonGen dgen(ndef, data->seed, water_level);
- dgen.generate(vm, blockseed, full_node_min, full_node_max);
+ DungeonGen dgen(this, NULL);
+ dgen.generate(blockseed, full_node_min, full_node_max);
}
for (size_t i = 0; i != emerge->decorations.size(); i++) {
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
- if (!(flags & MG_NOLIGHT))
+ if (flags & MG_LIGHT)
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
//setLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
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);
}
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;
return;
MapNode n_stone(c_stone);
- u32 index = 0;
+ u32 j = 0;
for (s16 z = node_min.Z; z <= node_max.Z; z++)
for (s16 y = node_min.Y; y <= node_max.Y; y++) {
u32 vi = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; x++) {
- int j = (z - node_min.Z) * csize.X + (x - node_min.X);
+ int index = (z - node_min.Z) * csize.X + (x - node_min.X);
- if (getMountainTerrainFromMap(index, j, y))
+ if (getMountainTerrainFromMap(j, index, y))
vm->m_data[vi] = n_stone;
vi++;
- index++;
+ j++;
}
}
}
// boundary, but the chunk above has not been generated yet
if (y == node_max.Y && c_above == CONTENT_IGNORE &&
y == heightmap[index] && c == c_stone) {
- int j = z * zstride + y * ystride + x;
+ int j = (z - node_min.Z) * zstride +
+ (y - node_min.Y) * ystride +
+ (x - node_min.X);
have_air = !getMountainTerrainFromMap(j, index, y);
}
#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;
for (u32 i = 0; i < bruises_count; i++) {
CaveV7 cave(this, &ps, true);
cave.makeCave(node_min, node_max, max_stone_y);
- }
+ }
}