]> git.lizzy.rs Git - minetest.git/blobdiff - src/dungeongen.cpp
Biome API: Enable biome generation to lower world limit
[minetest.git] / src / dungeongen.cpp
index 7462c275e515c67bce7b3fdc578d1383575661ab..7e292024da8c170014d9aa593ec09fe6ac6f6621 100644 (file)
@@ -26,8 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "map.h"
 #include "nodedef.h"
 #include "profiler.h"
-#include "settings.h" // For g_settings
-#include "main.h" // For g_profiler
+#include "settings.h"
 
 //#define DGEN_USE_TORCHES
 
@@ -70,10 +69,7 @@ DungeonGen::DungeonGen(Mapgen *mapgen, DungeonParams *dparams) {
 
 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;
@@ -82,14 +78,17 @@ void DungeonGen::generate(u32 bseed, v3s16 nmin, v3s16 nmax) {
        // Dungeon generator doesn't modify places which have this set
        vm->clearFlag(VMANIP_FLAG_DUNGEON_INSIDE | VMANIP_FLAG_DUNGEON_PRESERVE);
 
-       // Set all air and water to be untouchable to make dungeons open
-       // to caves and open air
+       bool no_float = !g_settings->getBool("enable_floating_dungeons");
+
+       // Set all air and water (and optionally ignore) to be untouchable
+       // to make dungeons open to caves and open air
        for (s16 z = nmin.Z; z <= nmax.Z; z++) {
                for (s16 y = nmin.Y; y <= nmax.Y; y++) {
                        u32 i = vm->m_area.index(nmin.X, y, z);
                        for (s16 x = nmin.X; x <= nmax.X; x++) {
                                content_t c = vm->m_data[i].getContent();
-                               if (c == CONTENT_AIR || c == dp.c_water)
+                               if (c == CONTENT_AIR || c == dp.c_water
+                                               || (no_float && c == CONTENT_IGNORE))
                                        vm->m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
                                i++;
                        }