aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2017-07-28 03:31:11 +0100
committerparamat <mat.gregory@virginmedia.com>2017-07-30 18:40:55 +0100
commitb20d01a3f19ea7ad1e788077af1ed5769648e3a1 (patch)
tree2d30ee6e8771bfddeb5140e4304e03795ef81190 /src
parent238d752fa3021fa7294a4df79bfa0b8a46f4a018 (diff)
downloadminetest-b20d01a3f19ea7ad1e788077af1ed5769648e3a1.tar.gz
minetest-b20d01a3f19ea7ad1e788077af1ed5769648e3a1.tar.bz2
minetest-b20d01a3f19ea7ad1e788077af1ed5769648e3a1.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/mapgen.cpp34
-rw-r--r--src/mapgen.h8
-rw-r--r--src/mapgen_carpathian.cpp7
-rw-r--r--src/mapgen_flat.cpp7
-rw-r--r--src/mapgen_fractal.cpp7
-rw-r--r--src/mapgen_v5.cpp7
-rw-r--r--src/mapgen_v7.cpp7
-rw-r--r--src/mapgen_valleys.cpp6
8 files changed, 61 insertions, 22 deletions
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index f73930e6e..cec59389d 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -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);
diff --git a/src/mapgen.h b/src/mapgen.h
index 7f4b76c3e..931622d3c 100644
--- a/src/mapgen.h
+++ b/src/mapgen.h
@@ -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:
diff --git a/src/mapgen_carpathian.cpp b/src/mapgen_carpathian.cpp
index 598795830..6a9daf759 100644
--- a/src/mapgen_carpathian.cpp
+++ b/src/mapgen_carpathian.cpp
@@ -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)
diff --git a/src/mapgen_flat.cpp b/src/mapgen_flat.cpp
index 9ae9d208c..34074c8b7 100644
--- a/src/mapgen_flat.cpp
+++ b/src/mapgen_flat.cpp
@@ -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)
diff --git a/src/mapgen_fractal.cpp b/src/mapgen_fractal.cpp
index 720408dbb..3663599a5 100644
--- a/src/mapgen_fractal.cpp
+++ b/src/mapgen_fractal.cpp
@@ -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)
diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp
index ad1e9d0a5..faca0e16a 100644
--- a/src/mapgen_v5.cpp
+++ b/src/mapgen_v5.cpp
@@ -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)
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index e63c648bc..f254a74d8 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -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)
diff --git a/src/mapgen_valleys.cpp b/src/mapgen_valleys.cpp
index ff56c69da..f0c145934 100644
--- a/src/mapgen_valleys.cpp
+++ b/src/mapgen_valleys.cpp
@@ -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)