@@ -1090,13 +1090,13 @@ static bool RiverMakeWider(TileIndex til
/* If the tile is already sea or river, don't expand. */
if (IsWaterTile(tile)) return false;
/* If the tile is at height 0 after terraforming but the ocean hasn't flooded yet, don't build river. */
if (GetTileMaxZ(tile) == 0) return false;
TileIndex origin_tile = *(TileIndex *)data;;
TileIndex origin_tile = *(TileIndex *)data;
Slope cur_slope = GetTileSlope(tile);
Slope desired_slope = GetTileSlope(origin_tile); // Initialize matching the origin tile as a shortcut if no terraforming is needed.
/* Never flow uphill. */
if (GetTileMaxZ(tile) > GetTileMaxZ(origin_tile)) return false;
@@ -1128,13 +1128,13 @@ static bool RiverMakeWider(TileIndex til
desired_slope = other_slope;
sloped_river_found = true;
break;
}
/* If we find an adjacent river tile, remember it. We'll terraform to match it later if we don't find a slope. */
if (IsTileFlat(tile)) flat_river_found = true;
if (IsTileFlat(other_tile)) flat_river_found = true;
/* We didn't find either an inclined or flat river, so we're climbing the wrong slope. Bail out. */
if (!sloped_river_found && !flat_river_found) return false;
/* We didn't find an inclined river, but there is a flat river. */
@@ -1200,30 +1200,40 @@ static bool RiverMakeWider(TileIndex til
/* If downstream is dry, flat, and not ocean, try making it a river tile. */
if (!IsWaterTile(downstream_tile) && !downstream_is_ocean) {
/* If the tile upstream isn't flat, don't bother. */
if (GetTileSlope(downstream_tile) != SLOPE_FLAT) return false;
MakeRiver(downstream_tile, Random());
MarkTileDirtyByTile(downstream_tile);
/* Remove desert directly around the river tile. */
TileIndex cur_tile = downstream_tile;
CircularTileSearch(&cur_tile, RIVER_OFFSET_DESERT_DISTANCE, RiverModifyDesertZone, nullptr);
/* If upstream is dry and flat, try making it a river tile. */
if (!IsWaterTile(upstream_tile)) {
if (GetTileSlope(upstream_tile) != SLOPE_FLAT) return false;
MakeRiver(upstream_tile, Random());
MarkTileDirtyByTile(upstream_tile);
TileIndex cur_tile = upstream_tile;
/* If the tile slope matches the desired slope, add a river tile. */
if (cur_slope == desired_slope) {
MakeRiver(tile, Random());
MarkTileDirtyByTile(tile);
TileIndex cur_tile = tile;
MarkTileDirtyByTile(cur_tile);
/* Always return false to keep searching. */
return false;
@@ -1491,12 +1501,15 @@ static void CreateRivers()
TileIndex t = RandomTile();
if (!CircularTileSearch(&t, 8, FindSpring, nullptr)) continue;
if (std::get<0>(FlowRiver(t, t, _settings_game.game_creation.min_river_length))) break;
/* Widening rivers may have left some tiles requiring to be watered. */
ConvertGroundTilesIntoWaterTiles();
/* Run tile loop to update the ground density. */
for (uint i = 0; i != 256; i++) {
if (i % 64 == 0) IncreaseGeneratingWorldProgress(GWP_RIVER);
RunTileLoop();
Status change: