]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Dungeons: Avoid generation in multiple liquid nodes and 'airlike'
authorparamat <paramat@users.noreply.github.com>
Mon, 12 Feb 2018 00:52:44 +0000 (00:52 +0000)
committerparamat <mat.gregory@virginmedia.com>
Tue, 13 Feb 2018 03:48:39 +0000 (03:48 +0000)
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.

src/mapgen/dungeongen.cpp
src/mapgen/dungeongen.h
src/mapgen/mapgen.cpp
src/mapgen/mapgen_v6.cpp

index 634139a27b569ad9ea9dbf9b233f85ee80622602..b5d7ec7adcbcae4ec6b88f5554f54756106b88be 100644 (file)
@@ -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++;
                                }
index 182581447f4a0ce9496c64370572c43b9f3eb61d..1e3d8375db53fc9911b3aeef779dbc42ecc76e89 100644 (file)
@@ -41,8 +41,6 @@ int dir_to_facedir(v3s16 d);
 struct DungeonParams {
        s32 seed;
 
-       content_t c_water;
-       content_t c_river_water;
        content_t c_wall;
        content_t c_alt_wall;
        content_t c_stair;
index d967d428a0c591ce4ec644e76db19d21ff8569c6..69aa174dab45f274d616eec81e2ea72ded9d9a62 100644 (file)
@@ -886,8 +886,6 @@ void MapgenBasic::generateDungeons(s16 max_stone_y,
        DungeonParams dp;
 
        dp.seed             = seed;
-       dp.c_water          = c_water_source;
-       dp.c_river_water    = c_river_water_source;
 
        dp.only_in_ground   = true;
        dp.corridor_len_min = 1;
index 9a638bb53cf3e263ddacaa3b3587eadb6a586663..92f131dcdc726d3a5187da28754b648a6a51a4b9 100644 (file)
@@ -557,8 +557,6 @@ void MapgenV6::makeChunk(BlockMakeData *data)
                DungeonParams dp;
 
                dp.seed             = seed;
-               dp.c_water          = c_water_source;
-               dp.c_river_water    = c_water_source;
 
                dp.only_in_ground   = true;
                dp.corridor_len_min = 1;