summaryrefslogtreecommitdiff
path: root/src/mapgen/dungeongen.cpp
diff options
context:
space:
mode:
authorparamat <paramat@users.noreply.github.com>2018-02-12 00:52:44 +0000
committerparamat <mat.gregory@virginmedia.com>2018-02-13 03:48:39 +0000
commit861cfd848473db6c36b0debb7152d98ca8017062 (patch)
tree3a46ec477b361010b43b361bc9910c8b57dbc2be /src/mapgen/dungeongen.cpp
parent1156088db740fed69051201fb943feaff3b4f678 (diff)
downloadminetest-861cfd848473db6c36b0debb7152d98ca8017062.tar.gz
minetest-861cfd848473db6c36b0debb7152d98ca8017062.tar.bz2
minetest-861cfd848473db6c36b0debb7152d98ca8017062.zip
Dungeons: Avoid generation in multiple liquid nodes and 'airlike'
Previously only 'mapgen water source' and 'mapgen river water source' were checked for. Games can use multiple liquid nodes defined for biomes, many of which will not be aliased to those 2 mapgen aliases, causing floating dungeons to generate in some liquids. Now we check for liquid drawtype instead, so can remove liquid nodes from dungeonparams. Also check for 'airlike' drawtype instead of 'CONTENT_AIR' to avoid generation in 'airlike' nodes in some rare situations. This will also be needed for when we add definable biome air nodes.
Diffstat (limited to 'src/mapgen/dungeongen.cpp')
-rw-r--r--src/mapgen/dungeongen.cpp23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/mapgen/dungeongen.cpp b/src/mapgen/dungeongen.cpp
index 634139a27..b5d7ec7ad 100644
--- a/src/mapgen/dungeongen.cpp
+++ b/src/mapgen/dungeongen.cpp
@@ -55,14 +55,9 @@ DungeonGen::DungeonGen(const NodeDefManager *ndef,
// Default dungeon parameters
dp.seed = 0;
- dp.c_water = ndef->getId("mapgen_water_source");
- dp.c_river_water = ndef->getId("mapgen_river_water_source");
- dp.c_wall = ndef->getId("mapgen_cobble");
- dp.c_alt_wall = ndef->getId("mapgen_mossycobble");
- dp.c_stair = ndef->getId("mapgen_stair_cobble");
-
- if (dp.c_river_water == CONTENT_IGNORE)
- dp.c_river_water = ndef->getId("mapgen_water_source");
+ dp.c_wall = ndef->getId("mapgen_cobble");
+ dp.c_alt_wall = ndef->getId("mapgen_mossycobble");
+ dp.c_stair = ndef->getId("mapgen_stair_cobble");
dp.diagonal_dirs = false;
dp.only_in_ground = true;
@@ -107,17 +102,17 @@ 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. Optionally set ignore to be untouchable to
- // prevent protruding dungeons.
+ // Set all air and liquid drawtypes to be untouchable to make dungeons
+ // open to air and liquids. Optionally set ignore to be untouchable to
+ // prevent projecting 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)
+ NodeDrawType dtype = ndef->get(c).drawtype;
+ if (dtype == NDT_AIRLIKE || dtype == NDT_LIQUID ||
+ (preserve_ignore && c == CONTENT_IGNORE))
vm->m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
i++;
}