}
-void MapgenBasic::generateCaves(s16 max_stone_y, s16 large_cave_depth)
+void MapgenBasic::generateCavesNoiseIntersection(s16 max_stone_y)
{
- if (max_stone_y < node_min.Y)
+ if (node_min.Y > max_stone_y)
return;
CavesNoiseIntersection caves_noise(ndef, m_bmgr, csize,
&np_cave1, &np_cave2, seed, cave_width);
caves_noise.generateCaves(vm, node_min, node_max, biomemap);
+}
+
- if (node_max.Y > large_cave_depth)
+void MapgenBasic::generateCavesRandomWalk(s16 max_stone_y, s16 large_cave_depth)
+{
+ if (node_min.Y > max_stone_y || node_max.Y > large_cave_depth)
return;
PseudoRandom ps(blockseed + 21343);
u32 bruises_count = ps.range(0, 2);
+
for (u32 i = 0; i < bruises_count; i++) {
CavesRandomWalk cave(ndef, &gennotify, seed, water_level,
c_water_source, c_lava_source, lava_depth, biomegen);
}
-bool MapgenBasic::generateCaverns(s16 max_stone_y)
+bool MapgenBasic::generateCavernsNoise(s16 max_stone_y)
{
if (node_min.Y > max_stone_y || node_min.Y > cavern_limit)
return false;
MapgenBasic(int mapgenid, MapgenParams *params, EmergeManager *emerge);
virtual ~MapgenBasic();
- virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);
- virtual bool generateCaverns(s16 max_stone_y);
- virtual void generateDungeons(s16 max_stone_y);
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 bool generateCavernsNoise(s16 max_stone_y);
+ virtual void generateDungeons(s16 max_stone_y);
protected:
EmergeManager *m_emerge;
biomegen->calcBiomeNoise(node_min);
generateBiomes();
- // Generate caverns, tunnels and classic caves
+ // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
- bool has_cavern = false;
+ // Generate tunnels first as caverns confuse them
+ generateCavesNoiseIntersection(stone_surface_max_y);
+
// Generate caverns
+ bool near_cavern = false;
if (spflags & MGCARPATHIAN_CAVERNS)
- has_cavern = generateCaverns(stone_surface_max_y);
- // Generate tunnels and classic caves
- if (has_cavern)
- // Disable classic caves in this mapchunk by setting
+ near_cavern = generateCavernsNoise(stone_surface_max_y);
+
+ // Generate large randomwalk caves
+ if (near_cavern)
+ // Disable large randomwalk caves in this mapchunk by setting
// 'large cave depth' to world base. Avoids excessive liquid in
// large caverns and floating blobs of overgenerated liquid.
- generateCaves(stone_surface_max_y, -MAX_MAP_GENERATION_LIMIT);
+ generateCavesRandomWalk(stone_surface_max_y,
+ -MAX_MAP_GENERATION_LIMIT);
else
- generateCaves(stone_surface_max_y, large_cave_depth);
+ generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
}
// Generate dungeons
biomegen->calcBiomeNoise(node_min);
generateBiomes();
- if (flags & MG_CAVES)
- generateCaves(stone_surface_max_y, large_cave_depth);
+ if (flags & MG_CAVES) {
+ // Generate tunnels
+ generateCavesNoiseIntersection(stone_surface_max_y);
+ // Generate large randomwalk caves
+ generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
+ }
if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
full_node_max.Y <= dungeon_ymax)
biomegen->calcBiomeNoise(node_min);
generateBiomes();
- if (flags & MG_CAVES)
- generateCaves(stone_surface_max_y, large_cave_depth);
+ if (flags & MG_CAVES) {
+ // Generate tunnels
+ generateCavesNoiseIntersection(stone_surface_max_y);
+ // Generate large randomwalk caves
+ generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
+ }
if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
full_node_max.Y <= dungeon_ymax)
biomegen->calcBiomeNoise(node_min);
generateBiomes();
- // Generate caverns, tunnels and classic caves
+ // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
- bool near_cavern = false;
+ // Generate tunnels first as caverns confuse them
+ generateCavesNoiseIntersection(stone_surface_max_y);
+
// Generate caverns
+ bool near_cavern = false;
if (spflags & MGV5_CAVERNS)
- near_cavern = generateCaverns(stone_surface_max_y);
- // Generate tunnels and classic caves
+ near_cavern = generateCavernsNoise(stone_surface_max_y);
+
+ // Generate large randomwalk caves
if (near_cavern)
- // Disable classic caves in this mapchunk by setting
+ // Disable large randomwalk caves in this mapchunk by setting
// 'large cave depth' to world base. Avoids excessive liquid in
// large caverns and floating blobs of overgenerated liquid.
- generateCaves(stone_surface_max_y, -MAX_MAP_GENERATION_LIMIT);
+ generateCavesRandomWalk(stone_surface_max_y,
+ -MAX_MAP_GENERATION_LIMIT);
else
- generateCaves(stone_surface_max_y, large_cave_depth);
+ generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
}
// Generate dungeons and desert temples
biomegen->calcBiomeNoise(node_min);
generateBiomes();
- // Generate caverns, tunnels and classic caves
+ // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
- bool near_cavern = false;
+ // Generate tunnels first as caverns confuse them
+ generateCavesNoiseIntersection(stone_surface_max_y);
+
// Generate caverns
+ bool near_cavern = false;
if (spflags & MGV7_CAVERNS)
- near_cavern = generateCaverns(stone_surface_max_y);
- // Generate tunnels and classic caves
+ near_cavern = generateCavernsNoise(stone_surface_max_y);
+
+ // Generate large randomwalk caves
if (near_cavern)
- // Disable classic caves in this mapchunk by setting
+ // Disable large randomwalk caves in this mapchunk by setting
// 'large cave depth' to world base. Avoids excessive liquid in
// large caverns and floating blobs of overgenerated liquid.
- generateCaves(stone_surface_max_y, -MAX_MAP_GENERATION_LIMIT);
+ generateCavesRandomWalk(stone_surface_max_y,
+ -MAX_MAP_GENERATION_LIMIT);
else
- generateCaves(stone_surface_max_y, large_cave_depth);
+ generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
}
// Generate dungeons
// Place biome-specific nodes and build biomemap
generateBiomes();
- // Generate caverns, tunnels and classic caves
+ // Generate tunnels, caverns and large randomwalk caves
if (flags & MG_CAVES) {
+ // Generate tunnels first as caverns confuse them
+ generateCavesNoiseIntersection(stone_surface_max_y);
+
// Generate caverns
- bool near_cavern = generateCaverns(stone_surface_max_y);
- // Generate tunnels and classic caves
+ bool near_cavern = generateCavernsNoise(stone_surface_max_y);
+
+ // Generate large randomwalk caves
if (near_cavern)
- // Disable classic caves in this mapchunk by setting
+ // Disable large randomwalk caves in this mapchunk by setting
// 'large cave depth' to world base. Avoids excessive liquid in
// large caverns and floating blobs of overgenerated liquid.
- generateCaves(stone_surface_max_y, -MAX_MAP_GENERATION_LIMIT);
+ generateCavesRandomWalk(stone_surface_max_y,
+ -MAX_MAP_GENERATION_LIMIT);
else
- generateCaves(stone_surface_max_y, large_cave_depth);
+ generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
}
// Dungeon creation