diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index a2ca438942..d38fd1ff17 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -69,7 +69,7 @@ static bool CanPlantTreesOnTile(TileIndex tile, bool allow_desert) { if ((_settings_game.game_creation.tree_placer == TP_PERFECT) && (_settings_game.game_creation.landscape == LT_ARCTIC) && - (GetTileZ(tile) > (_settings_game.game_creation.snow_line_height + _settings_game.construction.trees_around_snow_line_range))) { + (GetTileZ(tile) > (HighestSnowLine() + _settings_game.construction.trees_around_snow_line_range))) { return false; } @@ -194,7 +194,14 @@ static TreeType GetRandomTreeType(TileIndex tile, uint seed) if (range != _previous_trees_around_snow_line_range) RecalculateArcticTreeOccuranceArray(); int z = GetTileZ(tile); - int height_above_snow_line = z - _settings_game.game_creation.snow_line_height; + int height_above_snow_line = 0; + + if (z > HighestSnowLine()) { + height_above_snow_line = z - HighestSnowLine(); + } + else if (z < LowestSnowLine()) { + height_above_snow_line = z - LowestSnowLine(); + } uint normalised_distance = (height_above_snow_line < 0) ? -height_above_snow_line : height_above_snow_line + 1; bool arctic_tree = false; if (normalised_distance < _arctic_tree_occurance.size()) { @@ -358,7 +365,7 @@ int MaxTreeCount(const TileIndex tile) if (_settings_game.game_creation.landscape == LT_ARCTIC) { if (_settings_game.construction.trees_around_snow_line_range != _previous_trees_around_snow_line_range) RecalculateArcticTreeOccuranceArray(); - const uint height_above_snow_line = std::max(0, tile_z - _settings_game.game_creation.snow_line_height); + const uint height_above_snow_line = std::max(0, tile_z - HighestSnowLine()); max_trees_snow_line_based = (height_above_snow_line < _arctic_tree_occurance.size()) ? (1 + (_arctic_tree_occurance[height_above_snow_line] * 4) / 255) : 0; @@ -969,7 +976,7 @@ static void TileLoop_Trees(TileIndex tile) if (_settings_game.game_creation.tree_placer == TP_PERFECT && ((_settings_game.game_creation.landscape != LT_TROPIC && GetTileZ(tile) <= GetSparseTreeRange()) || (GetTreeType(tile) == TREE_CACTUS) || - (_settings_game.game_creation.landscape == LT_ARCTIC && GetTileZ(tile) >= _settings_game.game_creation.snow_line_height + _settings_game.construction.trees_around_snow_line_range / 3))) { + (_settings_game.game_creation.landscape == LT_ARCTIC && GetTileZ(tile) >= HighestSnowLine() + _settings_game.construction.trees_around_snow_line_range / 3))) { // On lower levels we spread more randomly to not bunch up. if (GetTreeType(tile) != TREE_CACTUS || (RandomRange(100) < 50)) { PlantTreeAtSameHeight(tile);