/* 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);
// Partial example, for the first 3 tiles:
int delta_counts[] = {2, 1, 1};
int side_counts[] = {0, 1, -1};
for (int m = -1; m <= 1; m += 2) {
for (int i = 0; i < lengthof(delta_counts); i++) {
TileIndex tc = tile + delta_counts[i] * delta_mid + m * delta_side * side_counts[i];
// Process tile.
if (side_counts[i] != 0) {
if (IsWaterTile(tc)) {
TileIndex tr = tc + delta_mid;
if (!IsWaterTile(tr) && IsTileFlat(tr)) {
MakeRiver(tr, Random());
/* Remove desert directly around the river tile. */
CircularTileSearch(&tr, 5, RiverModifyDesertZone, NULL);
}
}
} else {
if (!IsWaterTile(tc)) {
MakeRiver(tc, Random());
/* Remove desert directly around the river tile. */
CircularTileSearch(&tc, 5, RiverModifyDesertZone, NULL);
}
}
}
}
}
}