Loading

Paste #pduluvw6w

  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.             DoCommand(tile, 0, 0, DC_EXEC | CommandFlagsToDCFlags(GetCommandFlags(CMD_BUILD_LOCK)), CMD_BUILD_LOCK);
  5.  
  6.             Slope slope = GetTileSlope(tile);
  7.             DiagDirection dir = GetInclinedSlopeDirection(slope);
  8.             int delta_side = TileOffsByDiagDir(ChangeDiagDir(dir, DIAGDIRDIFF_90RIGHT));
  9.             int delta_mid = TileOffsByDiagDir(dir);
  10.  
  11.             TileIndex tile_upper_centre = tile + 2 * delta_mid;
  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;
  17.  
  18.             TileIndex tile_lower_centre = tile - 2 * delta_mid;
  19.             TileIndex tile_lower_right = tile - delta_mid + delta_side;
  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;
  24.  
  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};
  26.             for (int i = 0; i < lengthof(tiles); i++) {
  27.                 if (tiles[i] != INVALID_TILE && !IsWaterTile(tiles[i]) && IsTileFlat(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.     }

Comments