mirror of https://github.com/OpenTTD/OpenTTD
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
parent
64724b8893
commit
08ed68bc85
|
@ -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_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 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_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.
|
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.
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,7 @@ static void PlaceTreeAtSameHeight(TileIndex tile, int height)
|
||||||
void PlaceTreesRandomly()
|
void PlaceTreesRandomly()
|
||||||
{
|
{
|
||||||
int i, j, ht;
|
int i, j, ht;
|
||||||
|
uint8_t max_height = _settings_game.construction.map_height_limit;
|
||||||
|
|
||||||
i = Map::ScaleBySize(DEFAULT_TREE_STEPS);
|
i = Map::ScaleBySize(DEFAULT_TREE_STEPS);
|
||||||
if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV;
|
if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV;
|
||||||
|
@ -268,6 +269,8 @@ void PlaceTreesRandomly()
|
||||||
j = GetTileZ(tile) * 2;
|
j = GetTileZ(tile) * 2;
|
||||||
/* Above snowline more trees! */
|
/* Above snowline more trees! */
|
||||||
if (_settings_game.game_creation.landscape == LandscapeType::Arctic && ht > GetSnowLine()) j *= 3;
|
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--) {
|
while (j--) {
|
||||||
PlaceTreeAtSameHeight(tile, ht);
|
PlaceTreeAtSameHeight(tile, ht);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue