diff options
author | Charles Pigott <charlespigott@googlemail.com> | 2021-01-08 10:16:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 11:16:18 +0100 |
commit | 9b800a96ed32720ff60b74e498a0e0a6351004f9 (patch) | |
tree | 3f287d339e15c4902ee415556475fd9b2918d33c /src/tgp.cpp | |
parent | c1fddb9a6ae5c3af6865461a7295788a341011a2 (diff) | |
download | openttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz |
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/tgp.cpp')
-rw-r--r-- | src/tgp.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/tgp.cpp b/src/tgp.cpp index fb5c69cf7..f6d902255 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -234,8 +234,8 @@ static height_t TGPGetMaxHeight() { 12, 19, 25, 31, 67, 75, 87 }, ///< Alpinist }; - int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS]; - return I2H(min(max_height_from_table, _settings_game.construction.max_heightlevel)); + int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][std::min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS]; + return I2H(std::min<uint>(max_height_from_table, _settings_game.construction.max_heightlevel)); } /** @@ -270,7 +270,7 @@ static amplitude_t GetAmplitude(int frequency) /* Get the table index, and return that value if possible. */ int index = frequency - MAX_TGP_FREQUENCIES + lengthof(amplitudes[smoothness]); - amplitude_t amplitude = amplitudes[smoothness][max(0, index)]; + amplitude_t amplitude = amplitudes[smoothness][std::max(0, index)]; if (index >= 0) return amplitude; /* We need to extrapolate the amplitude. */ @@ -349,7 +349,7 @@ static void HeightMapGenerate() /* Trying to apply noise to uninitialized height map */ assert(_height_map.h != nullptr); - int start = max(MAX_TGP_FREQUENCIES - (int)min(MapLogX(), MapLogY()), 0); + int start = std::max(MAX_TGP_FREQUENCIES - (int)std::min(MapLogX(), MapLogY()), 0); bool first = true; for (int frequency = start; frequency < MAX_TGP_FREQUENCIES; frequency++) { @@ -725,7 +725,7 @@ static double perlin_coast_noise_2D(const double x, const double y, const double */ static void HeightMapCoastLines(uint8 water_borders) { - int smallest_size = min(_settings_game.game_creation.map_x, _settings_game.game_creation.map_y); + int smallest_size = std::min(_settings_game.game_creation.map_x, _settings_game.game_creation.map_y); const int margin = 4; int y, x; double max_x; @@ -736,7 +736,7 @@ static void HeightMapCoastLines(uint8 water_borders) if (HasBit(water_borders, BORDER_NE)) { /* Top right */ max_x = abs((perlin_coast_noise_2D(_height_map.size_y - y, y, 0.9, 53) + 0.25) * 5 + (perlin_coast_noise_2D(y, y, 0.35, 179) + 1) * 12); - max_x = max((smallest_size * smallest_size / 64) + max_x, (smallest_size * smallest_size / 64) + margin - max_x); + max_x = std::max((smallest_size * smallest_size / 64) + max_x, (smallest_size * smallest_size / 64) + margin - max_x); if (smallest_size < 8 && max_x > 5) max_x /= 1.5; for (x = 0; x < max_x; x++) { _height_map.height(x, y) = 0; @@ -746,7 +746,7 @@ static void HeightMapCoastLines(uint8 water_borders) if (HasBit(water_borders, BORDER_SW)) { /* Bottom left */ max_x = abs((perlin_coast_noise_2D(_height_map.size_y - y, y, 0.85, 101) + 0.3) * 6 + (perlin_coast_noise_2D(y, y, 0.45, 67) + 0.75) * 8); - max_x = max((smallest_size * smallest_size / 64) + max_x, (smallest_size * smallest_size / 64) + margin - max_x); + max_x = std::max((smallest_size * smallest_size / 64) + max_x, (smallest_size * smallest_size / 64) + margin - max_x); if (smallest_size < 8 && max_x > 5) max_x /= 1.5; for (x = _height_map.size_x; x > (_height_map.size_x - 1 - max_x); x--) { _height_map.height(x, y) = 0; @@ -759,7 +759,7 @@ static void HeightMapCoastLines(uint8 water_borders) if (HasBit(water_borders, BORDER_NW)) { /* Top left */ max_y = abs((perlin_coast_noise_2D(x, _height_map.size_y / 2, 0.9, 167) + 0.4) * 5 + (perlin_coast_noise_2D(x, _height_map.size_y / 3, 0.4, 211) + 0.7) * 9); - max_y = max((smallest_size * smallest_size / 64) + max_y, (smallest_size * smallest_size / 64) + margin - max_y); + max_y = std::max((smallest_size * smallest_size / 64) + max_y, (smallest_size * smallest_size / 64) + margin - max_y); if (smallest_size < 8 && max_y > 5) max_y /= 1.5; for (y = 0; y < max_y; y++) { _height_map.height(x, y) = 0; @@ -769,7 +769,7 @@ static void HeightMapCoastLines(uint8 water_borders) if (HasBit(water_borders, BORDER_SE)) { /* Bottom right */ max_y = abs((perlin_coast_noise_2D(x, _height_map.size_y / 3, 0.85, 71) + 0.25) * 6 + (perlin_coast_noise_2D(x, _height_map.size_y / 3, 0.35, 193) + 0.75) * 12); - max_y = max((smallest_size * smallest_size / 64) + max_y, (smallest_size * smallest_size / 64) + margin - max_y); + max_y = std::max((smallest_size * smallest_size / 64) + max_y, (smallest_size * smallest_size / 64) + margin - max_y); if (smallest_size < 8 && max_y > 5) max_y /= 1.5; for (y = _height_map.size_y; y > (_height_map.size_y - 1 - max_y); y--) { _height_map.height(x, y) = 0; @@ -809,7 +809,7 @@ static void HeightMapSmoothCoastInDirection(int org_x, int org_y, int dir_x, int * Soften the coast slope */ for (depth = 0; IsValidXY(x, y) && depth <= max_coast_Smooth_depth; depth++, x += dir_x, y += dir_y) { h = _height_map.height(x, y); - h = min(h, h_prev + (4 + depth)); // coast softening formula + h = std::min<uint>(h, h_prev + (4 + depth)); // coast softening formula _height_map.height(x, y) = h; h_prev = h; } @@ -842,13 +842,13 @@ static void HeightMapSmoothSlopes(height_t dh_max) { for (int y = 0; y <= (int)_height_map.size_y; y++) { for (int x = 0; x <= (int)_height_map.size_x; x++) { - height_t h_max = min(_height_map.height(x > 0 ? x - 1 : x, y), _height_map.height(x, y > 0 ? y - 1 : y)) + dh_max; + height_t h_max = std::min(_height_map.height(x > 0 ? x - 1 : x, y), _height_map.height(x, y > 0 ? y - 1 : y)) + dh_max; if (_height_map.height(x, y) > h_max) _height_map.height(x, y) = h_max; } } for (int y = _height_map.size_y; y >= 0; y--) { for (int x = _height_map.size_x; x >= 0; x--) { - height_t h_max = min(_height_map.height(x < _height_map.size_x ? x + 1 : x, y), _height_map.height(x, y < _height_map.size_y ? y + 1 : y)) + dh_max; + height_t h_max = std::min(_height_map.height(x < _height_map.size_x ? x + 1 : x, y), _height_map.height(x, y < _height_map.size_y ? y + 1 : y)) + dh_max; if (_height_map.height(x, y) > h_max) _height_map.height(x, y) = h_max; } } |