diff options
author | Patric Stout <truebrain@openttd.org> | 2021-03-24 10:29:01 +0100 |
---|---|---|
committer | Patric Stout <github@truebrain.nl> | 2021-03-26 12:22:32 +0100 |
commit | 422e132845255264314cd79aa14361d0df0905d7 (patch) | |
tree | 21452e883fa2a1bec4280625fb0ce7a6dfb168b8 /src/tgp.cpp | |
parent | 1a1049bc0db4e29402e950e56f3a6873c1f5a0ab (diff) | |
download | openttd-422e132845255264314cd79aa14361d0df0905d7.tar.xz |
Feature: auto-detect map height limit based on generated map
This opens up the true power of the TGP terrain generator, as it
is no longer constrainted by an arbitrary low map height limit,
especially for extreme terrain types.
In other words: on a 1kx1k map with "Alpinist" terrain type, the
map is now really hilly with default settings.
People can still manually limit the map height if they so wish,
and after the terrain generation the limit is stored in the
savegame as if the user set it.
Cheats still allow you to change this value.
Diffstat (limited to 'src/tgp.cpp')
-rw-r--r-- | src/tgp.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/tgp.cpp b/src/tgp.cpp index 92e714d9b..3ced2a1b0 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -237,7 +237,20 @@ static height_t TGPGetMaxHeight() int map_size_bucket = std::min(MapLogX(), MapLogY()) - MIN_MAP_SIZE_BITS; int max_height_from_table = max_height[_settings_game.difficulty.terrain_type][map_size_bucket]; - return I2H(std::min<uint>(max_height_from_table, _settings_game.construction.map_height_limit)); + /* If there is a manual map height limit, clamp to it. */ + if (_settings_game.construction.map_height_limit != 0) { + max_height_from_table = std::min<uint>(max_height_from_table, _settings_game.construction.map_height_limit); + } + + return I2H(max_height_from_table); +} + +/** + * Get an overestimation of the highest peak TGP wants to generate. + */ +uint GetEstimationTGPMapHeight() +{ + return H2I(TGPGetMaxHeight()); } /** |