Skip to content

Commit

Permalink
Dungeons: Move duplicated y limit checks to generation function
Browse files Browse the repository at this point in the history
  • Loading branch information
paramat committed Nov 23, 2019
1 parent b50a166 commit ec5f591
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 13 deletions.
3 changes: 2 additions & 1 deletion src/mapgen/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions src/mapgen/mapgen_carpathian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/mapgen/mapgen_flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/mapgen/mapgen_fractal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/mapgen/mapgen_v5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/mapgen/mapgen_v7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/mapgen/mapgen_valleys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ec5f591

Please sign in to comment.