Dungeons: Move duplicated y limit checks to generation function
authorparamat <paramat@users.noreply.github.com>
Fri, 22 Nov 2019 19:48:18 +0000 (19:48 +0000)
committerParamat <paramat@users.noreply.github.com>
Sat, 23 Nov 2019 01:41:27 +0000 (01:41 +0000)
src/mapgen/mapgen.cpp
src/mapgen/mapgen_carpathian.cpp
src/mapgen/mapgen_flat.cpp
src/mapgen/mapgen_fractal.cpp
src/mapgen/mapgen_v5.cpp
src/mapgen/mapgen_v7.cpp
src/mapgen/mapgen_valleys.cpp

index f465c05a05619fc30f6d8bdc71332848c1faa96f..5c6a95a820ee2067cc8bb0186a0b726b06b516b5 100644 (file)
@@ -886,7 +886,8 @@ bool MapgenBasic::generateCavernsNoise(s16 max_stone_y)
 
 void MapgenBasic::generateDungeons(s16 max_stone_y)
 {
-       if (max_stone_y < node_min.Y)
+       if (node_min.Y > max_stone_y || node_min.Y > dungeon_ymax ||
+                       node_max.Y < dungeon_ymin)
                return;
 
        u16 num_dungeons = std::fmax(std::floor(
index b0783c998d5a0b52af348aacc405f8a878cbf515..67f542c0dd519d218af5d5d62a829a22ddfe79c5 100644 (file)
@@ -313,8 +313,7 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
        m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
 
        // Generate dungeons
-       if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
-                       full_node_max.Y <= dungeon_ymax)
+       if (flags & MG_DUNGEONS)
                generateDungeons(stone_surface_max_y);
 
        // Generate the registered decorations
index 5cd4752020080d60b4ac55763451532eed642fd1..656e7d72c71c46b87e5e7a7839fa19f912035cde 100644 (file)
@@ -231,8 +231,7 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
        // Generate the registered ores
        m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
 
-       if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
-                       full_node_max.Y <= dungeon_ymax)
+       if (flags & MG_DUNGEONS)
                generateDungeons(stone_surface_max_y);
 
        // Generate the registered decorations
index 0431714fe43984daceff7b36c2ef75c5fce9ea81..1ac57cedec60bd691d437a35b9575fd63463c3cd 100644 (file)
@@ -249,8 +249,7 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
        m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
 
        // Generate dungeons
-       if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
-                       full_node_max.Y <= dungeon_ymax)
+       if (flags & MG_DUNGEONS)
                generateDungeons(stone_surface_max_y);
 
        // Generate the registered decorations
index 73fc4229534c917b16ac7bec8b9cc8dde5071f75..c003c27d66ba1895e3817751c9c881cf60bbdb01 100644 (file)
@@ -252,8 +252,7 @@ void MapgenV5::makeChunk(BlockMakeData *data)
        m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
 
        // Generate dungeons and desert temples
-       if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
-                       full_node_max.Y <= dungeon_ymax)
+       if (flags & MG_DUNGEONS)
                generateDungeons(stone_surface_max_y);
 
        // Generate the registered decorations
index a3cd8a557638d1aac67f8e655cd18b8e1588270b..43b73ebaea24b314107f9d46619a5cb3e72b3f7e 100644 (file)
@@ -372,8 +372,7 @@ void MapgenV7::makeChunk(BlockMakeData *data)
        m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
 
        // Generate dungeons
-       if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
-                       full_node_max.Y <= dungeon_ymax)
+       if (flags & MG_DUNGEONS)
                generateDungeons(stone_surface_max_y);
 
        // Generate the registered decorations
index c4ea5067d43b53e12bd94c93f7a49e51154c070c..3c6045105074ae2a6ebe787bd765fc6121ebb2dc 100644 (file)
@@ -260,8 +260,7 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
        m_emerge->oremgr->placeAllOres(this, blockseed, node_min, node_max);
 
        // Dungeon creation
-       if ((flags & MG_DUNGEONS) && full_node_min.Y >= dungeon_ymin &&
-                       full_node_max.Y <= dungeon_ymax)
+       if (flags & MG_DUNGEONS)
                generateDungeons(stone_surface_max_y);
 
        // Generate the registered decorations