/* 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))) {
DoCommand(tile, 0, 0, DC_EXEC | CommandFlagsToDCFlags(GetCommandFlags(CMD_BUILD_LOCK)), CMD_BUILD_LOCK);
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 = HasTileWaterGround(tile_upper_centre) ? INVALID_TILE : tile_upper_centre;
TileIndex tile_upper_upper_right = HasTileWaterGround(tile_upper_right) ? tile_upper_centre + delta_side : INVALID_TILE;
TileIndex tile_upper_upper_left = HasTileWaterGround(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 = HasTileWaterGround(tile_lower_centre) ? INVALID_TILE : tile_lower_centre;
TileIndex tile_lower_lower_right = HasTileWaterGround(tile_lower_right) ? tile_lower_centre + delta_side : INVALID_TILE;
TileIndex tile_lower_lower_left = HasTileWaterGround(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 && !IsWaterTile(tiles[i]) && IsTileFlat(tiles[i])) {
MakeRiver(tiles[i], Random());
/* Remove desert directly around the river tile. */
CircularTileSearch(&tiles[i], 5, RiverModifyDesertZone, NULL);
}
}
}
}