aboutsummaryrefslogtreecommitdiff
path: root/src/mapgen.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mapgen.cpp')
-rw-r--r--src/mapgen.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index fe7f74cfa..1d72ec037 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -633,6 +633,7 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
u16 base_filler = 0;
u16 depth_water_top = 0;
u16 depth_riverbed = 0;
+ s16 biome_y_min = -MAX_MAP_GENERATION_LIMIT;
u32 vi = vm->m_area.index(x, node_max.Y, z);
// Check node at base of mapchunk above, either a node of a previously
@@ -650,22 +651,20 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
for (s16 y = node_max.Y; y >= node_min.Y; y--) {
content_t c = vm->m_data[vi].getContent();
-
- // Biome is recalculated each time an upper surface is detected while
- // working down a column. The selected biome then remains in effect for
- // all nodes below until the next surface and biome recalculation.
- // Biome is recalculated:
+ // Biome is (re)calculated:
// 1. At the surface of stone below air or water.
// 2. At the surface of water below air.
// 3. When stone or water is detected but biome has not yet been calculated.
+ // 4. When stone or water is detected just below a biome's lower limit.
bool is_stone_surface = (c == c_stone) &&
- (air_above || water_above || !biome);
+ (air_above || water_above || !biome || y < biome_y_min); // 1, 3, 4
bool is_water_surface =
(c == c_water_source || c == c_river_water_source) &&
- (air_above || !biome);
+ (air_above || !biome || y < biome_y_min); // 2, 3, 4
if (is_stone_surface || is_water_surface) {
+ // (Re)calculate biome
// Limit to +-MAX MAP GENERATION LIMIT to work with biome y_min / y_max.
s32 relative_y = rangelim(y - biome_zero_level,
-MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
@@ -677,9 +676,11 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
depth_top = biome->depth_top;
base_filler = MYMAX(depth_top +
biome->depth_filler +
- noise_filler_depth->result[index], 0.f);
+ noise_filler_depth->result[index], 0.0f);
depth_water_top = biome->depth_water_top;
depth_riverbed = biome->depth_riverbed;
+ biome_y_min = rangelim(biome->y_min + biome_zero_level,
+ -MAX_MAP_GENERATION_LIMIT, MAX_MAP_GENERATION_LIMIT);
// Detect stone type for dungeons during every biome calculation.
// If none detected the last selected biome stone is chosen.