1
0
Fork 0

Fix: Too many trees when generating trees at same height. (#13460)

Multiplying by tile height caused far too many trees to be generated when using maps higher than the original limit.
pull/13468/head
Peter Nelson 2025-02-03 19:35:05 +00:00 committed by GitHub
parent 64724b8893
commit 08ed68bc85
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,8 @@ static const uint CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY = 4; ///< Value for custom
static const uint CUSTOM_SEA_LEVEL_MIN_PERCENTAGE = 1; ///< Minimum percentage a user can specify for custom sea level.
static const uint CUSTOM_SEA_LEVEL_MAX_PERCENTAGE = 90; ///< Maximum percentage a user can specify for custom sea level.
static constexpr uint MAP_HEIGHT_LIMIT_ORIGINAL = 15; ///< Original map height limit.
static const uint MAP_HEIGHT_LIMIT_AUTO_MINIMUM = 30; ///< When map height limit is auto, make this the lowest possible map height limit.
static const uint MAP_HEIGHT_LIMIT_AUTO_CEILING_ROOM = 15; ///< When map height limit is auto, the map height limit will be the higest peak plus this value.

View File

@ -247,6 +247,7 @@ static void PlaceTreeAtSameHeight(TileIndex tile, int height)
void PlaceTreesRandomly()
{
int i, j, ht;
uint8_t max_height = _settings_game.construction.map_height_limit;
i = Map::ScaleBySize(DEFAULT_TREE_STEPS);
if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV;
@ -268,6 +269,8 @@ void PlaceTreesRandomly()
j = GetTileZ(tile) * 2;
/* Above snowline more trees! */
if (_settings_game.game_creation.landscape == LandscapeType::Arctic && ht > GetSnowLine()) j *= 3;
/* Scale generation by maximum map height. */
if (max_height > MAP_HEIGHT_LIMIT_ORIGINAL) j = j * MAP_HEIGHT_LIMIT_ORIGINAL / max_height;
while (j--) {
PlaceTreeAtSameHeight(tile, ht);
}