/* Create additional river tiles around possible lock locations to connect them. */ for (uint tile = 0; tile != MapSize(); tile++) { if (IsValidTile(tile) && IsTileType(tile, MP_WATER) && IsRiver(tile) && IsInclinedSlope(GetTileSlope(tile))) { Slope slope = GetTileSlope(tile); DiagDirection dir = GetInclinedSlopeDirection(slope); int delta_side = TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT)); int delta_mid = TileOffsByDiagDir(dir); TileIndex tile_upper_centre = tile + 2 * delta_mid; TileIndex tile_upper_right = tile + delta_mid + delta_side; TileIndex tile_upper_left = tile + delta_mid - delta_side; TileIndex tile_upper_upper = IsWaterTile(tile_upper_centre) ? INVALID_TILE : tile_upper_centre; TileIndex tile_upper_upper_right = IsWaterTile(tile_upper_right) ? tile_upper_centre + delta_side : INVALID_TILE; TileIndex tile_upper_upper_left = IsWaterTile(tile_upper_left) ? tile_upper_centre - delta_side : INVALID_TILE; TileIndex tile_lower_centre = tile - 2 * delta_mid; TileIndex tile_lower_right = tile - delta_mid + delta_side; TileIndex tile_lower_left = tile - delta_mid - delta_side; TileIndex tile_lower_lower = IsWaterTile(tile_lower_centre) ? INVALID_TILE : tile_lower_centre; TileIndex tile_lower_lower_right = IsWaterTile(tile_lower_right) ? tile_lower_centre + delta_side : INVALID_TILE; TileIndex tile_lower_lower_left = IsWaterTile(tile_lower_left) ? tile_lower_centre - delta_side : INVALID_TILE; TileIndex tiles[] = {tile_upper_upper, tile_upper_upper_right, tile_upper_upper_left, tile_lower_lower, tile_lower_lower_right, tile_lower_lower_left}; for (int i = 0; i < lengthof(tiles); i++) { if (tiles[i] != INVALID_TILE && IsTileFlat(tiles[i])) { assert(!IsWaterTile(tiles[i])); MakeRiver(tiles[i], Random()); /* Remove desert directly around the river tile. */ CircularTileSearch(&tiles[i], 5, RiverModifyDesertZone, NULL); } } } }