5 |
| 4 |
|
---|
6 | Slope slope = GetTileSlope(tile);
| 5 | Slope slope = GetTileSlope(tile);
|
---|
7 | DiagDirection dir = GetInclinedSlopeDirection(slope);
| 6 | DiagDirection dir = GetInclinedSlopeDirection(slope);
|
---|
8 | int delta_side = TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT));
| 7 | int delta_side = TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT));
|
---|
9 | int delta_mid = TileOffsByDiagDir(dir);
| 8 | int delta_mid = TileOffsByDiagDir(dir);
|
---|
10 |
| 9 |
|
---|
11 | TileIndex tile_upper_centre = tile + 2 * delta_mid;
| 11 | // Partial example, for the first 3 tiles:
|
---|
12 | TileIndex tile_upper_right = tile + delta_mid + delta_side;
| | |
---|
13 | TileIndex tile_upper_left = tile + delta_mid - delta_side;
| | |
---|
14 | TileIndex tile_upper_upper = HasTileWaterGround(tile_upper_centre) ? INVALID_TILE : tile_upper_centre;
| | |
---|
15 | TileIndex tile_upper_upper_right = HasTileWaterGround(tile_upper_right) ? tile_upper_centre + delta_side : INVALID_TILE;
| | |
---|
16 | TileIndex tile_upper_upper_left = HasTileWaterGround(tile_upper_left) ? tile_upper_centre - delta_side : INVALID_TILE;
| | |
---|
18 | TileIndex tile_lower_centre = tile - 2 * delta_mid;
| 18 | int delta_counts[] = {2, 1, 1};
|
---|
19 | TileIndex tile_lower_right = tile - delta_mid + delta_side;
| 19 | int side_counts[] = {0, 1, -1};
|
---|
20 | TileIndex tile_lower_left = tile - delta_mid - delta_side;
| | |
---|
21 | TileIndex tile_lower_lower = HasTileWaterGround(tile_lower_centre) ? INVALID_TILE : tile_lower_centre;
| | |
---|
22 | TileIndex tile_lower_lower_right = HasTileWaterGround(tile_lower_right) ? tile_lower_centre + delta_side : INVALID_TILE;
| | |
---|
23 | TileIndex tile_lower_lower_left = HasTileWaterGround(tile_lower_left) ? tile_lower_centre - delta_side : INVALID_TILE;
| | |
---|
25 | TileIndex tiles[] = {tile_upper_upper, tile_upper_upper_right, tile_upper_upper_left, tile_lower_lower, tile_lower_lower_right, tile_lower_lower_left};
| 15 | for (int m = -1; m <= 1; m += 2) {
|
---|
26 | for (int i = 0; i < lengthof(tiles); i++) {
| 16 | for (int i = 0; i < lengthof(delta_counts); i++) {
|
---|
27 | if (tiles[i] != INVALID_TILE && !IsWaterTile(tiles[i]) && IsTileFlat(tiles[i])) {
| 17 | TileIndex tc = tile + delta_counts[i] * delta_mid + m * delta_side * side_counts[i];
|
---|
28 | MakeRiver(tiles[i], Random());
| 18 | // Process tile.
|
---|
29 | /* Remove desert directly around the river tile. */
| 19 | if (side_counts[i] != 0) {
|
---|
30 | CircularTileSearch(&tiles[i], 5, RiverModifyDesertZone, NULL);
| 20 | if (IsWaterTile(tc)) {
|
---|
| | 21 | TileIndex tr = tc + delta_mid;
|
---|
| | 22 | if (!IsWaterTile(tr) && IsTileFlat(tr)) {
|
---|
| | 23 | MakeRiver(tr, Random());
|
---|
| | 24 | /* Remove desert directly around the river tile. */
|
---|
| | 25 | CircularTileSearch(&tr, 5, RiverModifyDesertZone, NULL);
|
---|
| | 26 | }
|
---|
| | 27 | }
|
---|
| | 28 | } else {
|
---|
| | 29 | if (!IsWaterTile(tc)) {
|
---|
| | 30 | MakeRiver(tc, Random());
|
---|
| | 31 | /* Remove desert directly around the river tile. */
|
---|
| | 32 | CircularTileSearch(&tc, 5, RiverModifyDesertZone, NULL);
|
---|
| | 33 | }
|
---|
| | 34 | }
|
---|