Loading

Paste #pxyftsh2y

  1.     /* Create additional river tiles around possible lock locations to connect them. */
  2.     for (uint tile = 0; tile != MapSize(); tile++) {
  3.         if (IsValidTile(tile) && IsTileType(tile, MP_WATER) && IsRiver(tile) && IsInclinedSlope(GetTileSlope(tile))) {
  4.  
  5.             Slope slope = GetTileSlope(tile);
  6.             DiagDirection dir = GetInclinedSlopeDirection(slope);
  7.             int delta_side = TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT));
  8.             int delta_mid = TileOffsByDiagDir(dir);
  9.  
  10.             TileIndex tile_upper_centre = tile + 2 * delta_mid;
  11.             TileIndex tile_upper_right = tile + delta_mid + delta_side;
  12.             TileIndex tile_upper_left = tile + delta_mid - delta_side;
  13.             TileIndex tile_upper_upper = IsWaterTile(tile_upper_centre) ? INVALID_TILE : tile_upper_centre;
  14.             TileIndex tile_upper_upper_right = IsWaterTile(tile_upper_right) ? tile_upper_centre + delta_side : INVALID_TILE;
  15.             TileIndex tile_upper_upper_left = IsWaterTile(tile_upper_left) ? tile_upper_centre - delta_side : INVALID_TILE;
  16.  
  17.             TileIndex tile_lower_centre = tile - 2 * delta_mid;
  18.             TileIndex tile_lower_right = tile - delta_mid + delta_side;
  19.             TileIndex tile_lower_left = tile - delta_mid - delta_side;
  20.             TileIndex tile_lower_lower = IsWaterTile(tile_lower_centre) ? INVALID_TILE : tile_lower_centre;
  21.             TileIndex tile_lower_lower_right = IsWaterTile(tile_lower_right) ? tile_lower_centre + delta_side : INVALID_TILE;
  22.             TileIndex tile_lower_lower_left = IsWaterTile(tile_lower_left) ? tile_lower_centre - delta_side : INVALID_TILE;
  23.  
  24.             TileIndex tiles[] = {tile_upper_upper, tile_upper_upper_right, tile_upper_upper_left, tile_lower_lower, tile_lower_lower_right, tile_lower_lower_left};
  25.             for (int i = 0; i < lengthof(tiles); i++) {
  26.                 if (tiles[i] != INVALID_TILE && IsTileFlat(tiles[i])) {
  27.                     assert(!IsWaterTile(tiles[i]));
  28.                     MakeRiver(tiles[i], Random());
  29.                     /* Remove desert directly around the river tile. */
  30.                     CircularTileSearch(&tiles[i], 5, RiverModifyDesertZone, NULL);
  31.                 }
  32.             }
  33.         }
  34.     }

Version history

Revision # Author Created at
pduluvw6w Anonymous 23 Nov 2017, 12:51:59 UTC Diff

Comments