Changeset - r26647:e9a4288831dd
[Not reviewed]
master
0 1 0
2TallTyler - 18 months ago 2022-12-13 18:30:58
tyler@tylertrahan.com
Fix #10218: Sloped river tiles need water both up and downstream
1 file changed with 30 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/landscape.cpp
Show inline comments
 
@@ -1180,6 +1180,36 @@ static bool RiverMakeWider(TileIndex til
 
	/* Update cur_slope after possibly terraforming. */
 
	cur_slope = GetTileSlope(tile);
 

	
 
	/* Sloped rivers need water both upstream and downstream. */
 
	if (IsInclinedSlope(cur_slope)) {
 
		DiagDirection slope_direction = GetInclinedSlopeDirection(cur_slope);
 

	
 
		TileIndex upstream_tile = TileAddByDiagDir(tile, slope_direction);
 
		TileIndex downstream_tile = TileAddByDiagDir(tile, ReverseDiagDir(slope_direction));
 

	
 
		/* Don't look outside the map. */
 
		if (!IsValidTile(upstream_tile) || !IsValidTile(downstream_tile)) return false;
 

	
 
		/* Downstream might be new ocean created by our terraforming, and it hasn't flooded yet. */
 
		bool downstream_is_ocean = GetTileZ(downstream_tile) == 0 && (GetTileSlope(downstream_tile) == SLOPE_FLAT || IsSlopeWithOneCornerRaised(GetTileSlope(downstream_tile)));
 

	
 
		/* 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());
 
		}
 

	
 
		/* If upstream is dry and flat, try making it a river tile. */
 
		if (!IsWaterTile(upstream_tile)) {
 
			/* If the tile upstream isn't flat, don't bother. */
 
			if (GetTileSlope(upstream_tile) != SLOPE_FLAT) return false;
 

	
 
			MakeRiver(upstream_tile, Random());
 
		}
 
	}
 

	
 
	/* If the tile slope matches the desired slope, add a river tile. */
 
	if (cur_slope == desired_slope) {
 
		MakeRiver(tile, Random());
0 comments (0 inline, 0 general)