void DungeonGen::generate(u32 bseed, v3s16 nmin, v3s16 nmax) {
//TimeTaker t("gen dungeons");
- int approx_groundlevel = 10 + mg->water_level;
-
- if ((nmin.Y + nmax.Y) / 2 >= approx_groundlevel ||
- NoisePerlin3D(&dp.np_rarity, nmin.X, nmin.Y, nmin.Z, mg->seed) < 0.2)
+ if (NoisePerlin3D(&dp.np_rarity, nmin.X, nmin.Y, nmin.Z, mg->seed) < 0.2)
return;
this->blockseed = bseed;
calculateNoise();
// Generate base terrain
- generateBaseTerrain();
+ s16 stone_surface_max_y = generateBaseTerrain();
+
updateHeightmap(node_min, node_max);
// Generate underground dirt, sand, gravel and lava blobs
generateBiomes();
// Generate dungeons and desert temples
- if (flags & MG_DUNGEONS) {
+ if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
DungeonGen dgen(this, NULL);
dgen.generate(blockseed, full_node_min, full_node_max);
}
// Make base ground level
-void MapgenV5::generateBaseTerrain()
+int MapgenV5::generateBaseTerrain()
{
u32 index = 0;
u32 index2d = 0;
+ int stone_surface_max_y = -MAP_GENERATION_LIMIT;
for(s16 z=node_min.Z; z<=node_max.Z; z++) {
for(s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
vm->m_data[i] = MapNode(CONTENT_AIR);
} else {
vm->m_data[i] = MapNode(c_stone);
+ if (y > stone_surface_max_y)
+ stone_surface_max_y = y;
}
}
index2d = index2d - ystride;
}
index2d = index2d + ystride;
}
+
+ return stone_surface_max_y;
}
virtual void makeChunk(BlockMakeData *data);
int getGroundLevelAtPoint(v2s16 p);
void calculateNoise();
- void generateBaseTerrain();
+ int generateBaseTerrain();
void generateBlobs();
void generateBiomes();
void dustTopNodes();
}
// Add dungeons
- if (flags & MG_DUNGEONS) {
+ if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
DungeonParams dp;
dp.np_rarity = nparams_dungeon_rarity;
if (flags & MG_CAVES)
generateCaves(stone_surface_max_y);
- if (flags & MG_DUNGEONS) {
+ if ((flags & MG_DUNGEONS) && (stone_surface_max_y >= node_min.Y)) {
DungeonGen dgen(this, NULL);
dgen.generate(blockseed, full_node_min, full_node_max);
}
int ymax = generateBaseTerrain();
if (spflags & MGV7_MOUNTAINS)
- generateMountainTerrain();
+ ymax = generateMountainTerrain(ymax);
if (spflags & MGV7_RIDGES)
generateRidgeTerrain();
}
-void MapgenV7::generateMountainTerrain()
+int MapgenV7::generateMountainTerrain(int ymax)
{
if (node_max.Y <= water_level)
- return;
+ return ymax;
MapNode n_stone(c_stone);
u32 j = 0;
u32 vi = vm->m_area.index(node_min.X, y, z);
for (s16 x = node_min.X; x <= node_max.X; x++) {
int index = (z - node_min.Z) * csize.X + (x - node_min.X);
+ content_t c = vm->m_data[vi].getContent();
- if (getMountainTerrainFromMap(j, index, y))
+ if (getMountainTerrainFromMap(j, index, y)
+ && (c == CONTENT_AIR || c == c_water_source)) {
vm->m_data[vi] = n_stone;
+ if (y > ymax)
+ ymax = y;
+ }
vi++;
j++;
}
}
+
+ return ymax;
}
virtual int generateTerrain();
int generateBaseTerrain();
- void generateMountainTerrain();
+ int generateMountainTerrain(int ymax);
void generateRidgeTerrain();
void generateBiomes();