Skip to content

Commit

Permalink
Mgvalleys: fix riverbeds below sea level
Browse files Browse the repository at this point in the history
Stop riverbeds from forming plateaus under sea. Minor corrections to
random lava/water placement.
  • Loading branch information
duane-r authored and paramat committed Feb 2, 2016
1 parent 0a8af88 commit 99c905c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/mapgen_valleys.cpp
Expand Up @@ -99,8 +99,8 @@ MapgenValleys::MapgenValleys(int mapgenid, MapgenParams *params, EmergeManager *
this->water_features_lim = rangelim(sp->water_features, 0, 10);

// a small chance of overflows if the settings are very high
this->cave_water_max_height = water_level + MYMAX(0, water_features_lim - 6) * 50;
this->lava_max_height = water_level + MYMAX(0, lava_features_lim - 6) * 50;
this->cave_water_max_height = water_level + MYMAX(0, water_features_lim - 4) * 50;
this->lava_max_height = water_level + MYMAX(0, lava_features_lim - 4) * 50;

tcave_cache = new float[csize.Y + 2];

Expand Down Expand Up @@ -482,7 +482,8 @@ float MapgenValleys::terrainLevelFromNoise(TerrainNoise *tn)

// base - depth : height of the bottom of the river
// water_level - 6 : don't make rivers below 6 nodes under the surface
mount = rangelim(base - depth, (float) (water_level - 6), mount);
// There is no logical equivalent to this using rangelim.
mount = MYMIN(MYMAX(base - depth, (float) (water_level - 6)), mount);

// Slope has no influence on rivers.
*tn->slope = 0.f;
Expand Down Expand Up @@ -846,8 +847,8 @@ void MapgenValleys::generateCaves(s16 max_stone_y)

// Reduce the odds of overflows even further.
if (node_max.Y > water_level) {
lava_chance /= 5;
water_chance /= 5;
lava_chance /= 3;
water_chance /= 3;
}

u32 index_2d = 0;
Expand Down

0 comments on commit 99c905c

Please sign in to comment.