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.
This commit is contained in:
Patric Stout
2021-03-24 10:29:01 +01:00
committed by Patric Stout
parent 1a1049bc0d
commit 422e132845
8 changed files with 52 additions and 10 deletions

View File

@@ -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());
}
/**