Skip to content

Commit f92a393

Browse files
authoredAug 5, 2020
Mapgen Flat: Add caverns, disabled by default (#9913)
Add the caverns used in V5, V7, Valleys, Carpathian. Disabled by default to not be force-enabled in existing worlds.
1 parent 93ecc58 commit f92a393

File tree

4 files changed

+75
-26
lines changed

4 files changed

+75
-26
lines changed
 

‎builtin/mainmenu/dlg_create_world.lua

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ local flag_checkboxes = {
6161
fgettext("Low humidity and high heat causes shallow or dry rivers") },
6262
},
6363
flat = {
64+
cb_caverns,
6465
{ "hills", fgettext("Hills"), "hills" },
6566
{ "lakes", fgettext("Lakes"), "lakes" },
6667
},

‎builtin/settingtypes.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -1860,7 +1860,7 @@ mgcarpathian_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 50
18601860

18611861
# Map generation attributes specific to Mapgen Flat.
18621862
# Occasional lakes and hills can be added to the flat world.
1863-
mgflat_spflags (Mapgen Flat specific flags) flags nolakes,nohills lakes,hills,nolakes,nohills
1863+
mgflat_spflags (Mapgen Flat specific flags) flags nolakes,nohills,nocaverns lakes,hills,caverns,nolakes,nohills,nocaverns
18641864

18651865
# Y of flat ground.
18661866
mgflat_ground_level (Ground level) int 8
@@ -1904,6 +1904,15 @@ mgflat_hill_threshold (Hill threshold) float 0.45
19041904
# Controls steepness/height of hills.
19051905
mgflat_hill_steepness (Hill steepness) float 64.0
19061906

1907+
# Y-level of cavern upper limit.
1908+
mgflat_cavern_limit (Cavern limit) int -256
1909+
1910+
# Y-distance over which caverns expand to full size.
1911+
mgflat_cavern_taper (Cavern taper) int 256
1912+
1913+
# Defines full size of caverns, smaller values create larger caverns.
1914+
mgflat_cavern_threshold (Cavern threshold) float 0.7
1915+
19071916
# Lower Y limit of dungeons.
19081917
mgflat_dungeon_ymin (Dungeon minimum Y) int -31000
19091918

@@ -1924,6 +1933,9 @@ mgflat_np_cave1 (Cave1 noise) noise_params_3d 0, 12, (61, 61, 61), 52534, 3, 0.5
19241933
# Second of two 3D noises that together define tunnels.
19251934
mgflat_np_cave2 (Cave2 noise) noise_params_3d 0, 12, (67, 67, 67), 10325, 3, 0.5, 2.0
19261935

1936+
# 3D noise defining giant caverns.
1937+
mgflat_np_cavern (Cavern noise) noise_params_3d 0, 1, (384, 128, 384), 723, 5, 0.63, 2.0
1938+
19271939
# 3D noise that determines number of dungeons per mapchunk.
19281940
mgflat_np_dungeons (Dungeon noise) noise_params_3d 0.9, 0.5, (500, 500, 500), 0, 2, 0.8, 2.0
19291941

‎src/mapgen/mapgen_flat.cpp

+47-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Minetest
3-
Copyright (C) 2015-2018 paramat
4-
Copyright (C) 2015-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
3+
Copyright (C) 2015-2020 paramat
4+
Copyright (C) 2015-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU Lesser General Public License as published by
@@ -39,8 +39,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3939

4040

4141
FlagDesc flagdesc_mapgen_flat[] = {
42-
{"lakes", MGFLAT_LAKES},
43-
{"hills", MGFLAT_HILLS},
42+
{"lakes", MGFLAT_LAKES},
43+
{"hills", MGFLAT_HILLS},
44+
{"caverns", MGFLAT_CAVERNS},
4445
{NULL, 0}
4546
};
4647

@@ -52,17 +53,21 @@ MapgenFlat::MapgenFlat(MapgenFlatParams *params, EmergeParams *emerge)
5253
{
5354
spflags = params->spflags;
5455
ground_level = params->ground_level;
55-
large_cave_depth = params->large_cave_depth;
56+
lake_threshold = params->lake_threshold;
57+
lake_steepness = params->lake_steepness;
58+
hill_threshold = params->hill_threshold;
59+
hill_steepness = params->hill_steepness;
60+
61+
cave_width = params->cave_width;
5662
small_cave_num_min = params->small_cave_num_min;
5763
small_cave_num_max = params->small_cave_num_max;
5864
large_cave_num_min = params->large_cave_num_min;
5965
large_cave_num_max = params->large_cave_num_max;
66+
large_cave_depth = params->large_cave_depth;
6067
large_cave_flooded = params->large_cave_flooded;
61-
cave_width = params->cave_width;
62-
lake_threshold = params->lake_threshold;
63-
lake_steepness = params->lake_steepness;
64-
hill_threshold = params->hill_threshold;
65-
hill_steepness = params->hill_steepness;
68+
cavern_limit = params->cavern_limit;
69+
cavern_taper = params->cavern_taper;
70+
cavern_threshold = params->cavern_threshold;
6671
dungeon_ymin = params->dungeon_ymin;
6772
dungeon_ymax = params->dungeon_ymax;
6873

@@ -71,9 +76,11 @@ MapgenFlat::MapgenFlat(MapgenFlatParams *params, EmergeParams *emerge)
7176

7277
if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
7378
noise_terrain = new Noise(&params->np_terrain, seed, csize.X, csize.Z);
79+
7480
// 3D noise
7581
MapgenBasic::np_cave1 = params->np_cave1;
7682
MapgenBasic::np_cave2 = params->np_cave2;
83+
MapgenBasic::np_cavern = params->np_cavern;
7784
MapgenBasic::np_dungeons = params->np_dungeons;
7885
}
7986

@@ -88,11 +95,12 @@ MapgenFlat::~MapgenFlat()
8895

8996

9097
MapgenFlatParams::MapgenFlatParams():
91-
np_terrain (0, 1, v3f(600, 600, 600), 7244, 5, 0.6, 2.0),
92-
np_filler_depth (0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0),
93-
np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0),
94-
np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0),
95-
np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0)
98+
np_terrain (0, 1, v3f(600, 600, 600), 7244, 5, 0.6, 2.0),
99+
np_filler_depth (0, 1.2, v3f(150, 150, 150), 261, 3, 0.7, 2.0),
100+
np_cavern (0.0, 1.0, v3f(384, 128, 384), 723, 5, 0.63, 2.0),
101+
np_cave1 (0, 12, v3f(61, 61, 61), 52534, 3, 0.5, 2.0),
102+
np_cave2 (0, 12, v3f(67, 67, 67), 10325, 3, 0.5, 2.0),
103+
np_dungeons (0.9, 0.5, v3f(500, 500, 500), 0, 2, 0.8, 2.0)
96104
{
97105
}
98106

@@ -112,11 +120,15 @@ void MapgenFlatParams::readParams(const Settings *settings)
112120
settings->getFloatNoEx("mgflat_lake_steepness", lake_steepness);
113121
settings->getFloatNoEx("mgflat_hill_threshold", hill_threshold);
114122
settings->getFloatNoEx("mgflat_hill_steepness", hill_steepness);
123+
settings->getS16NoEx("mgflat_cavern_limit", cavern_limit);
124+
settings->getS16NoEx("mgflat_cavern_taper", cavern_taper);
125+
settings->getFloatNoEx("mgflat_cavern_threshold", cavern_threshold);
115126
settings->getS16NoEx("mgflat_dungeon_ymin", dungeon_ymin);
116127
settings->getS16NoEx("mgflat_dungeon_ymax", dungeon_ymax);
117128

118129
settings->getNoiseParams("mgflat_np_terrain", np_terrain);
119130
settings->getNoiseParams("mgflat_np_filler_depth", np_filler_depth);
131+
settings->getNoiseParams("mgflat_np_cavern", np_cavern);
120132
settings->getNoiseParams("mgflat_np_cave1", np_cave1);
121133
settings->getNoiseParams("mgflat_np_cave2", np_cave2);
122134
settings->getNoiseParams("mgflat_np_dungeons", np_dungeons);
@@ -138,11 +150,15 @@ void MapgenFlatParams::writeParams(Settings *settings) const
138150
settings->setFloat("mgflat_lake_steepness", lake_steepness);
139151
settings->setFloat("mgflat_hill_threshold", hill_threshold);
140152
settings->setFloat("mgflat_hill_steepness", hill_steepness);
153+
settings->setS16("mgflat_cavern_limit", cavern_limit);
154+
settings->setS16("mgflat_cavern_taper", cavern_taper);
155+
settings->setFloat("mgflat_cavern_threshold", cavern_threshold);
141156
settings->setS16("mgflat_dungeon_ymin", dungeon_ymin);
142157
settings->setS16("mgflat_dungeon_ymax", dungeon_ymax);
143158

144159
settings->setNoiseParams("mgflat_np_terrain", np_terrain);
145160
settings->setNoiseParams("mgflat_np_filler_depth", np_filler_depth);
161+
settings->setNoiseParams("mgflat_np_cavern", np_cavern);
146162
settings->setNoiseParams("mgflat_np_cave1", np_cave1);
147163
settings->setNoiseParams("mgflat_np_cave2", np_cave2);
148164
settings->setNoiseParams("mgflat_np_dungeons", np_dungeons);
@@ -226,11 +242,25 @@ void MapgenFlat::makeChunk(BlockMakeData *data)
226242
generateBiomes();
227243
}
228244

245+
// Generate tunnels, caverns and large randomwalk caves
229246
if (flags & MG_CAVES) {
230-
// Generate tunnels
247+
// Generate tunnels first as caverns confuse them
231248
generateCavesNoiseIntersection(stone_surface_max_y);
249+
250+
// Generate caverns
251+
bool near_cavern = false;
252+
if (spflags & MGFLAT_CAVERNS)
253+
near_cavern = generateCavernsNoise(stone_surface_max_y);
254+
232255
// Generate large randomwalk caves
233-
generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
256+
if (near_cavern)
257+
// Disable large randomwalk caves in this mapchunk by setting
258+
// 'large cave depth' to world base. Avoids excessive liquid in
259+
// large caverns and floating blobs of overgenerated liquid.
260+
generateCavesRandomWalk(stone_surface_max_y,
261+
-MAX_MAP_GENERATION_LIMIT);
262+
else
263+
generateCavesRandomWalk(stone_surface_max_y, large_cave_depth);
234264
}
235265

236266
// Generate the registered ores

‎src/mapgen/mapgen_flat.h

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
Minetest
3-
Copyright (C) 2015-2018 paramat
4-
Copyright (C) 2015-2018 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
3+
Copyright (C) 2015-2020 paramat
4+
Copyright (C) 2015-2016 kwolekr, Ryan Kwolek <kwolekr@minetest.net>
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU Lesser General Public License as published by
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2525
/////// Mapgen Flat flags
2626
#define MGFLAT_LAKES 0x01
2727
#define MGFLAT_HILLS 0x02
28+
#define MGFLAT_CAVERNS 0x04
2829

2930
class BiomeManager;
3031

@@ -33,22 +34,27 @@ extern FlagDesc flagdesc_mapgen_flat[];
3334
struct MapgenFlatParams : public MapgenParams
3435
{
3536
s16 ground_level = 8;
36-
s16 large_cave_depth = -33;
37+
float lake_threshold = -0.45f;
38+
float lake_steepness = 48.0f;
39+
float hill_threshold = 0.45f;
40+
float hill_steepness = 64.0f;
41+
42+
float cave_width = 0.09f;
3743
u16 small_cave_num_min = 0;
3844
u16 small_cave_num_max = 0;
3945
u16 large_cave_num_min = 0;
4046
u16 large_cave_num_max = 2;
47+
s16 large_cave_depth = -33;
4148
float large_cave_flooded = 0.5f;
42-
float cave_width = 0.09f;
43-
float lake_threshold = -0.45f;
44-
float lake_steepness = 48.0f;
45-
float hill_threshold = 0.45f;
46-
float hill_steepness = 64.0f;
49+
s16 cavern_limit = -256;
50+
s16 cavern_taper = 256;
51+
float cavern_threshold = 0.7f;
4752
s16 dungeon_ymin = -31000;
4853
s16 dungeon_ymax = 31000;
4954

5055
NoiseParams np_terrain;
5156
NoiseParams np_filler_depth;
57+
NoiseParams np_cavern;
5258
NoiseParams np_cave1;
5359
NoiseParams np_cave2;
5460
NoiseParams np_dungeons;

0 commit comments

Comments
 (0)
Please sign in to comment.