]> git.lizzy.rs Git - minetest.git/blobdiff - src/dungeongen.cpp
client.cpp: modernize code
[minetest.git] / src / dungeongen.cpp
index 6cef3f88dbd432c273ea2699db227ade13071ca4..f8859dcd0804f9dbcc78092e5a6fb6b42346159c 100644 (file)
@@ -97,6 +97,8 @@ void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax)
        if (nval_density < 1.0f)
                return;
 
+       static const bool preserve_ignore = !g_settings->getBool("projecting_dungeons");
+
        this->vm = vm;
        this->blockseed = bseed;
        random.seed(bseed + 2);
@@ -105,14 +107,16 @@ void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax)
        vm->clearFlag(VMANIP_FLAG_DUNGEON_INSIDE | VMANIP_FLAG_DUNGEON_PRESERVE);
 
        if (dp.only_in_ground) {
-               // Set all air and water to be untouchable
-               // to make dungeons open to caves and open air
+               // Set all air and water to be untouchable to make dungeons open to
+               // caves and open air. Optionally set ignore to be untouchable to
+               // prevent protruding dungeons.
                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 ||
+                                                       (preserve_ignore && c == CONTENT_IGNORE) ||
                                                        c == dp.c_river_water)
                                                vm->m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
                                        i++;
@@ -147,7 +151,7 @@ void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax)
 
 void DungeonGen::makeDungeon(v3s16 start_padding)
 {
-       v3s16 areasize = vm->m_area.getExtent();
+       const v3s16 &areasize = vm->m_area.getExtent();
        v3s16 roomsize;
        v3s16 roomplace;