Add setting for width of dynamic snowline range for arctic tree placement

Default: 75%
This commit is contained in:
Jonathan G Rennison
2022-05-01 00:41:08 +01:00
parent c183f07c15
commit 452d22ce37
7 changed files with 43 additions and 8 deletions

View File

@@ -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) > (HighestSnowLine() + _settings_game.construction.trees_around_snow_line_range))) {
(GetTileZ(tile) > (HighestTreePlacementSnowLine() + _settings_game.construction.trees_around_snow_line_range))) {
return false;
}
@@ -196,11 +196,10 @@ static TreeType GetRandomTreeType(TileIndex tile, uint seed)
int z = GetTileZ(tile);
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();
if (z > HighestTreePlacementSnowLine()) {
height_above_snow_line = z - HighestTreePlacementSnowLine();
} else if (z < LowestTreePlacementSnowLine()) {
height_above_snow_line = z - LowestTreePlacementSnowLine();
}
uint normalised_distance = (height_above_snow_line < 0) ? -height_above_snow_line : height_above_snow_line + 1;
bool arctic_tree = false;
@@ -365,7 +364,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<int>(0, tile_z - HighestSnowLine());
const uint height_above_snow_line = std::max<int>(0, tile_z - HighestTreePlacementSnowLine());
max_trees_snow_line_based = (height_above_snow_line < _arctic_tree_occurance.size()) ?
(1 + (_arctic_tree_occurance[height_above_snow_line] * 4) / 255) :
0;
@@ -976,7 +975,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) >= HighestSnowLine() + _settings_game.construction.trees_around_snow_line_range / 3))) {
(_settings_game.game_creation.landscape == LT_ARCTIC && GetTileZ(tile) >= HighestTreePlacementSnowLine() + _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);