* Make wetlands around the given tile. * @param centre The starting tile. * @param height The height of the wetlands. * @param river_length The length of the river. */
| 1095 | * @param river_length The length of the river. |
| 1096 | */ |
| 1097 | static void MakeWetlands(TileIndex centre, uint height, uint river_length) |
| 1098 | { |
| 1099 | MakeRiverAndModifyDesertZoneAround(centre); |
| 1100 | |
| 1101 | uint diameter = std::max((river_length), 16u); |
| 1102 | |
| 1103 | /* Some wetlands have trees planted among the water tiles. */ |
| 1104 | bool has_trees = Chance16(1, 2); |
| 1105 | |
| 1106 | /* Create the main wetland area. */ |
| 1107 | for (TileIndex tile : SpiralTileSequence(centre, diameter)) { |
| 1108 | if (!IsValidRiverTerminusTile(tile, height)) continue; |
| 1109 | |
| 1110 | /* Don't make a perfect square, but a circle with a noisy border. */ |
| 1111 | uint radius = diameter / 2; |
| 1112 | if ((DistanceSquare(tile, centre) > radius * radius) && Chance16(3, 4)) continue; |
| 1113 | |
| 1114 | if (Chance16(1, 3)) { |
| 1115 | /* This tile is water. */ |
| 1116 | MakeRiverAndModifyDesertZoneAround(tile); |
| 1117 | } else if (IsTileType(tile, MP_CLEAR)) { |
| 1118 | /* This tile is ground, which we always make rough. */ |
| 1119 | SetClearGroundDensity(tile, CLEAR_ROUGH, 3); |
| 1120 | /* Maybe place trees? */ |
| 1121 | if (has_trees && _settings_game.game_creation.tree_placer != TP_NONE) { |
| 1122 | PlaceTree(tile, Random(), true); |
| 1123 | } |
| 1124 | } |
| 1125 | } |
| 1126 | } |
| 1127 | |
| 1128 | /** |
| 1129 | * Try to end a river at a tile which is not the sea. |
no test coverage detected