MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / MakeWetlands

Function MakeWetlands

src/landscape.cpp:1097–1126  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

1095 * @param river_length The length of the river.
1096 */
1097static 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.

Callers 1

TryMakeRiverTerminusFunction · 0.85

Calls 9

Chance16Function · 0.85
SpiralTileSequenceClass · 0.85
IsValidRiverTerminusTileFunction · 0.85
DistanceSquareFunction · 0.85
IsTileTypeFunction · 0.85
SetClearGroundDensityFunction · 0.85
PlaceTreeFunction · 0.85
RandomFunction · 0.50

Tested by

no test coverage detected