Dungeons: Use biome 'node_stone' if normal stone types not detected

Construct dungeons from the node defined as biome 'node_stone' if
'mapgen_stone', 'mapgen_desert_stone' and 'mapgen_sandstone' are not
detected.
Feature long-intended by kwolekr/hmmmm and present in code as a TODO.
master
paramat 2017-07-28 03:31:11 +01:00 committed by paramat
parent 238d752fa3
commit b20d01a3f1
8 changed files with 61 additions and 22 deletions

View File

@ -621,7 +621,8 @@ MapgenBasic::~MapgenBasic()
}
MgStoneType MapgenBasic::generateBiomes(s16 biome_zero_level)
void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
content_t *biome_stone, s16 biome_zero_level)
{
// can't generate biomes without a biome generator!
assert(biomegen);
@ -629,7 +630,8 @@ MgStoneType MapgenBasic::generateBiomes(s16 biome_zero_level)
const v3s16 &em = vm->m_area.getExtent();
u32 index = 0;
MgStoneType stone_type = MGSTONE_STONE;
MgStoneType stone_type = MGSTONE_OTHER;
content_t c_biome_stone = c_stone;
noise_filler_depth->perlinMap2D(node_min.X, node_min.Z);
@ -689,12 +691,15 @@ MgStoneType MapgenBasic::generateBiomes(s16 biome_zero_level)
depth_riverbed = biome->depth_riverbed;
// Detect stone type for dungeons during every biome calculation.
// This is more efficient than detecting per-node and will not
// miss any desert stone or sandstone biomes.
if (biome->c_stone == c_desert_stone)
// If none detected the last selected biome stone is chosen.
if (biome->c_stone == c_stone)
stone_type = MGSTONE_STONE;
else if (biome->c_stone == c_desert_stone)
stone_type = MGSTONE_DESERT_STONE;
else if (biome->c_stone == c_sandstone)
stone_type = MGSTONE_SANDSTONE;
c_biome_stone = biome->c_stone;
}
if (c == c_stone) {
@ -755,7 +760,8 @@ MgStoneType MapgenBasic::generateBiomes(s16 biome_zero_level)
}
}
return stone_type;
*mgstone_type = stone_type;
*biome_stone = c_biome_stone;
}
@ -845,7 +851,8 @@ bool MapgenBasic::generateCaverns(s16 max_stone_y)
}
void MapgenBasic::generateDungeons(s16 max_stone_y, MgStoneType stone_type)
void MapgenBasic::generateDungeons(s16 max_stone_y,
MgStoneType stone_type, content_t biome_stone)
{
if (max_stone_y < node_min.Y)
return;
@ -908,6 +915,19 @@ void MapgenBasic::generateDungeons(s16 max_stone_y, MgStoneType stone_type)
dp.room_size_large_max = v3s16(18, 16, 18);
dp.notifytype = GENNOTIFY_DUNGEON;
break;
case MGSTONE_OTHER:
dp.c_wall = biome_stone;
dp.c_alt_wall = biome_stone;
dp.c_stair = biome_stone;
dp.diagonal_dirs = false;
dp.holesize = v3s16(1, 2, 1);
dp.room_size_min = v3s16(4, 4, 4);
dp.room_size_max = v3s16(8, 6, 8);
dp.room_size_large_min = v3s16(8, 8, 8);
dp.room_size_large_max = v3s16(16, 16, 16);
dp.notifytype = GENNOTIFY_DUNGEON;
break;
}
DungeonGen dgen(ndef, &gennotify, &dp);

View File

@ -79,11 +79,11 @@ enum GenNotifyType {
NUM_GENNOTIFY_TYPES
};
// TODO(hmmmm/paramat): make stone type selection dynamic
enum MgStoneType {
MGSTONE_STONE,
MGSTONE_DESERT_STONE,
MGSTONE_SANDSTONE,
MGSTONE_OTHER,
};
struct GenNotifyEvent {
@ -250,8 +250,10 @@ public:
virtual void generateCaves(s16 max_stone_y, s16 large_cave_depth);
virtual bool generateCaverns(s16 max_stone_y);
virtual void generateDungeons(s16 max_stone_y, MgStoneType stone_type);
virtual MgStoneType generateBiomes(s16 biome_zero_level = 0);
virtual void generateDungeons(s16 max_stone_y,
MgStoneType stone_type, content_t biome_stone);
virtual void generateBiomes(MgStoneType *mgstone_type,
content_t *biome_stone, s16 biome_zero_level);
virtual void dustTopNodes();
protected:

View File

@ -242,7 +242,10 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
// Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min);
MgStoneType stone_type = generateBiomes(water_level - 1);
MgStoneType mgstone_type;
content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1);
// Generate caverns, tunnels and classic caves
if (flags & MG_CAVES) {
@ -262,7 +265,7 @@ void MapgenCarpathian::makeChunk(BlockMakeData *data)
// Generate dungeons
if (flags & MG_DUNGEONS)
generateDungeons(stone_surface_max_y, stone_type);
generateDungeons(stone_surface_max_y, mgstone_type, biome_stone);
// Generate the registered decorations
if (flags & MG_DECORATIONS)

View File

@ -189,13 +189,16 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
// Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min);
MgStoneType stone_type = generateBiomes(water_level - 1);
MgStoneType mgstone_type;
content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1);
if (flags & MG_CAVES)
generateCaves(stone_surface_max_y, large_cave_depth);
if (flags & MG_DUNGEONS)
generateDungeons(stone_surface_max_y, stone_type);
generateDungeons(stone_surface_max_y, mgstone_type, biome_stone);
// Generate the registered decorations
if (flags & MG_DECORATIONS)

View File

@ -200,13 +200,16 @@ void MapgenFractal::makeChunk(BlockMakeData *data)
// Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min);
MgStoneType stone_type = generateBiomes(water_level - 1);
MgStoneType mgstone_type;
content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1);
if (flags & MG_CAVES)
generateCaves(stone_surface_max_y, large_cave_depth);
if (flags & MG_DUNGEONS)
generateDungeons(stone_surface_max_y, stone_type);
generateDungeons(stone_surface_max_y, mgstone_type, biome_stone);
// Generate the registered decorations
if (flags & MG_DECORATIONS)

View File

@ -200,7 +200,10 @@ void MapgenV5::makeChunk(BlockMakeData *data)
// Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min);
MgStoneType stone_type = generateBiomes(water_level - 1);
MgStoneType mgstone_type;
content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1);
// Generate caverns, tunnels and classic caves
if (flags & MG_CAVES) {
@ -220,7 +223,7 @@ void MapgenV5::makeChunk(BlockMakeData *data)
// Generate dungeons and desert temples
if (flags & MG_DUNGEONS)
generateDungeons(stone_surface_max_y, stone_type);
generateDungeons(stone_surface_max_y, mgstone_type, biome_stone);
// Generate the registered decorations
if (flags & MG_DECORATIONS)

View File

@ -308,7 +308,10 @@ void MapgenV7::makeChunk(BlockMakeData *data)
// Init biome generator, place biome-specific nodes, and build biomemap
biomegen->calcBiomeNoise(node_min);
MgStoneType stone_type = generateBiomes(biome_zero_level);
MgStoneType mgstone_type;
content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1);
// Generate caverns, tunnels and classic caves
if (flags & MG_CAVES) {
@ -328,7 +331,7 @@ void MapgenV7::makeChunk(BlockMakeData *data)
// Generate dungeons
if (flags & MG_DUNGEONS)
generateDungeons(stone_surface_max_y, stone_type);
generateDungeons(stone_surface_max_y, mgstone_type, biome_stone);
// Generate the registered decorations
if (flags & MG_DECORATIONS)

View File

@ -236,7 +236,9 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
updateHeightmap(node_min, node_max);
// Place biome-specific nodes and build biomemap
MgStoneType stone_type = generateBiomes(water_level - 1);
MgStoneType mgstone_type;
content_t biome_stone;
generateBiomes(&mgstone_type, &biome_stone, water_level - 1);
// Cave creation.
if (flags & MG_CAVES)
@ -244,7 +246,7 @@ void MapgenValleys::makeChunk(BlockMakeData *data)
// Dungeon creation
if ((flags & MG_DUNGEONS) && node_max.Y < 50)
generateDungeons(stone_surface_max_y, stone_type);
generateDungeons(stone_surface_max_y, mgstone_type, biome_stone);
// Generate the registered decorations
if (flags & MG_DECORATIONS)