Backport 'Dungeons: Add setting to prevent projecting dungeons' from MT 5.0

This commit is contained in:
MoNTE48 2019-06-07 20:58:59 +02:00
parent 5b0bc240e4
commit 6e6f141b44
4 changed files with 15 additions and 3 deletions

View File

@ -978,6 +978,9 @@ mapgen_limit (Map generation limit) int 31000 0 31000
# Flags starting with 'no' are used to explicitly disable them. # Flags starting with 'no' are used to explicitly disable them.
mg_flags (Mapgen flags) flags caves,dungeons,light,decorations caves,dungeons,light,decorations,nocaves,nodungeons,nolight,nodecorations mg_flags (Mapgen flags) flags caves,dungeons,light,decorations caves,dungeons,light,decorations,nocaves,nodungeons,nolight,nodecorations
# Whether dungeons occasionally project from the terrain.
projecting_dungeons (Projecting dungeons) bool true
[**Advanced] [**Advanced]
# Size of chunks to be generated at once by mapgen, stated in mapblocks (16 nodes). # Size of chunks to be generated at once by mapgen, stated in mapblocks (16 nodes).

View File

@ -1195,6 +1195,10 @@
# type: flags possible values: caves, dungeons, light, decorations, nocaves, nodungeons, nolight, nodecorations # type: flags possible values: caves, dungeons, light, decorations, nocaves, nodungeons, nolight, nodecorations
# mg_flags = caves,dungeons,light,decorations # mg_flags = caves,dungeons,light,decorations
# Whether dungeons occasionally project from the terrain.
# type: bool
# projecting_dungeons = true
### Advanced ### Advanced
# Size of chunks to be generated at once by mapgen, stated in mapblocks (16 nodes). # Size of chunks to be generated at once by mapgen, stated in mapblocks (16 nodes).

View File

@ -362,6 +362,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("mg_flags", "dungeons"); settings->setDefault("mg_flags", "dungeons");
settings->setDefault("fixed_map_seed", ""); settings->setDefault("fixed_map_seed", "");
settings->setDefault("max_block_generate_distance", "8"); settings->setDefault("max_block_generate_distance", "8");
settings->setDefault("projecting_dungeons", "false");
settings->setDefault("enable_mapgen_debug_info", "false"); settings->setDefault("enable_mapgen_debug_info", "false");
// Server list announcing // Server list announcing

View File

@ -97,6 +97,8 @@ void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax)
if (nval_density < 1.0f) if (nval_density < 1.0f)
return; return;
static const bool preserve_ignore = !g_settings->getBool("projecting_dungeons");
this->vm = vm; this->vm = vm;
this->blockseed = bseed; this->blockseed = bseed;
random.seed(bseed + 2); random.seed(bseed + 2);
@ -105,14 +107,16 @@ void DungeonGen::generate(MMVManip *vm, u32 bseed, v3s16 nmin, v3s16 nmax)
vm->clearFlag(VMANIP_FLAG_DUNGEON_INSIDE | VMANIP_FLAG_DUNGEON_PRESERVE); vm->clearFlag(VMANIP_FLAG_DUNGEON_INSIDE | VMANIP_FLAG_DUNGEON_PRESERVE);
if (dp.only_in_ground) { if (dp.only_in_ground) {
// Set all air and water to be untouchable // Set all air and water to be untouchable to make dungeons open to
// to make dungeons open to caves and open air // caves and open air. Optionally set ignore to be untouchable to
// prevent protruding dungeons.
for (s16 z = nmin.Z; z <= nmax.Z; z++) { for (s16 z = nmin.Z; z <= nmax.Z; z++) {
for (s16 y = nmin.Y; y <= nmax.Y; y++) { for (s16 y = nmin.Y; y <= nmax.Y; y++) {
u32 i = vm->m_area.index(nmin.X, y, z); u32 i = vm->m_area.index(nmin.X, y, z);
for (s16 x = nmin.X; x <= nmax.X; x++) { for (s16 x = nmin.X; x <= nmax.X; x++) {
content_t c = vm->m_data[i].getContent(); content_t c = vm->m_data[i].getContent();
if (c == CONTENT_AIR || c == dp.c_water || if (c == CONTENT_AIR || c == dp.c_water ||
(preserve_ignore && c == CONTENT_IGNORE) ||
c == dp.c_river_water) c == dp.c_river_water)
vm->m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE; vm->m_flags[i] |= VMANIP_FLAG_DUNGEON_PRESERVE;
i++; i++;
@ -154,7 +158,7 @@ void DungeonGen::makeDungeon(v3s16 start_padding)
/* /*
Find place for first room. Find place for first room.
There is a 1 in 4 chance of the first room being 'large', There is a 1 in 4 chance of the first room being 'large',
all other rooms are not 'large'. all other rooms are noif (dp.only_in_ground) {t 'large'.
*/ */
bool fits = false; bool fits = false;
for (u32 i = 0; i < 100 && !fits; i++) { for (u32 i = 0; i < 100 && !fits; i++) {