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.
This commit is contained in:
Peter Nelson
2025-02-03 19:35:05 +00:00
committed by GitHub
parent 64724b8893
commit 08ed68bc85
2 changed files with 5 additions and 0 deletions

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);
}