Add PR #231: More river configuration options

This commit is contained in:
reldred
2021-03-28 23:45:08 +01:00
committed by Jonathan G Rennison
parent 7e728fe9d6
commit 213b6fe6ef
7 changed files with 101 additions and 14 deletions

View File

@@ -1059,11 +1059,13 @@ static bool FindSpring(TileIndex tile, void *user_data)
if (num < 4) return false;
/* Are we near the top of a hill? */
for (int dx = -16; dx <= 16; dx++) {
for (int dy = -16; dy <= 16; dy++) {
TileIndex t = TileAddWrap(tile, dx, dy);
if (t != INVALID_TILE && GetTileMaxZ(t) > referenceHeight + 2) return false;
if (_settings_game.game_creation.rivers_top_of_hill) {
/* Are we near the top of a hill? */
for (int dx = -16; dx <= 16; dx++) {
for (int dy = -16; dy <= 16; dy++) {
TileIndex t = TileAddWrap(tile, dx, dy);
if (t != INVALID_TILE && GetTileMaxZ(t) > referenceHeight + 2) return false;
}
}
}
@@ -1088,7 +1090,7 @@ static bool MakeLake(TileIndex tile, void *user_data)
MakeRiver(tile, Random());
/* Remove desert directly around the river tile. */
TileIndex t = tile;
CircularTileSearch(&t, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr);
CircularTileSearch(&t, _settings_game.game_creation.river_tropics_width, RiverModifyDesertZone, nullptr);
return false;
}
}
@@ -1160,7 +1162,7 @@ static void River_FoundEndNode(AyStar *aystar, OpenListNode *current)
if (!IsWaterTile(tile)) {
MakeRiver(tile, Random());
/* Remove desert directly around the river tile. */
CircularTileSearch(&tile, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr);
CircularTileSearch(&tile, _settings_game.game_creation.river_tropics_width, RiverModifyDesertZone, nullptr);
}
}
}
@@ -1266,15 +1268,15 @@ static bool FlowRiver(TileIndex spring, TileIndex begin)
/* We don't want the lake at the entry of the valley. */
lakeCenter != begin &&
/* We don't want lakes in the desert. */
(_settings_game.game_creation.landscape != LT_TROPIC || GetTropicZone(lakeCenter) != TROPICZONE_DESERT) &&
(_settings_game.game_creation.landscape != LT_TROPIC || _settings_game.game_creation.lakes_allowed_in_deserts || GetTropicZone(lakeCenter) != TROPICZONE_DESERT) &&
/* We only want a lake if the river is long enough. */
DistanceManhattan(spring, lakeCenter) > _settings_game.game_creation.min_river_length) {
end = lakeCenter;
MakeRiver(lakeCenter, Random());
/* Remove desert directly around the river tile. */
CircularTileSearch(&lakeCenter, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr);
CircularTileSearch(&lakeCenter, _settings_game.game_creation.river_tropics_width, RiverModifyDesertZone, nullptr);
lakeCenter = end;
uint range = RandomRange(8) + 3;
uint range = RandomRange(_settings_game.game_creation.lake_size) + 3;
CircularTileSearch(&lakeCenter, range, MakeLake, &height);
/* Call the search a second time so artefacts from going circular in one direction get (mostly) hidden. */
lakeCenter = end;