Loading

Revision differences

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