Changeset - r24491:cc4c5b4cc2fc
[Not reviewed]
master
0 3 0
Pavel Stupnikov - 4 years ago 2020-12-24 23:36:54
dp@dpointer.org
Feature: Add an option to disable tree growth completely (#8415)
3 files changed with 18 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/lang/english.txt
Show inline comments
 
@@ -1611,27 +1611,28 @@ STR_CONFIG_SETTING_NOISE_LEVEL_HELPTEXT 
 
STR_CONFIG_SETTING_TOWN_FOUNDING                                :Founding towns in game: {STRING2}
 
STR_CONFIG_SETTING_TOWN_FOUNDING_HELPTEXT                       :Enabling this setting allows players to found new towns in the game
 
STR_CONFIG_SETTING_TOWN_FOUNDING_FORBIDDEN                      :Forbidden
 
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED                        :Allowed
 
STR_CONFIG_SETTING_TOWN_FOUNDING_ALLOWED_CUSTOM_LAYOUT          :Allowed, custom town layout
 
STR_CONFIG_SETTING_TOWN_CARGOGENMODE                            :Town cargo generation: {STRING2}
 
STR_CONFIG_SETTING_TOWN_CARGOGENMODE_HELPTEXT                   :How much cargo is produced by houses in towns, relative to the overall population of the town.{}Quadratic growth: A town twice the size generates four times as many passengers.{}Linear growth: A town twice the size generates twice the amount of passengers.
 
STR_CONFIG_SETTING_TOWN_CARGOGENMODE_ORIGINAL                   :Quadratic (original)
 
STR_CONFIG_SETTING_TOWN_CARGOGENMODE_BITCOUNT                   :Linear
 

	
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT                         :In game placement of trees: {STRING2}
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT                :Control random appearance of trees during the game. This might affect industries which rely on tree growth, for example lumber mills
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE                    :None {RED}(breaks lumber mill)
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_RAINFOREST              :Only in rain forests
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_ALL                     :Everywhere
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NO_SPREAD               :Grow but don't spread {RED}(breaks lumber mill)
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_SPREAD_RAINFOREST       :Grow but only spread in rain forests
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_SPREAD_ALL              :Grow and spread everywhere
 
STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NO_GROWTH_NO_SPREAD     :Don't grow, don't spread {RED}(breaks lumber mill)
 

	
 
STR_CONFIG_SETTING_TOOLBAR_POS                                  :Position of main toolbar: {STRING2}
 
STR_CONFIG_SETTING_TOOLBAR_POS_HELPTEXT                         :Horizontal position of the main toolbar at the top of the screen
 
STR_CONFIG_SETTING_STATUSBAR_POS                                :Position of status bar: {STRING2}
 
STR_CONFIG_SETTING_STATUSBAR_POS_HELPTEXT                       :Horizontal position of the status bar at the bottom of the screen
 
STR_CONFIG_SETTING_SNAP_RADIUS                                  :Window snap radius: {STRING2}
 
STR_CONFIG_SETTING_SNAP_RADIUS_HELPTEXT                         :Distance between windows before the window being moved is automatically aligned to nearby windows
 
STR_CONFIG_SETTING_SNAP_RADIUS_VALUE                            :{COMMA} pixel{P 0 "" s}
 
STR_CONFIG_SETTING_SNAP_RADIUS_DISABLED                         :Disabled
 
STR_CONFIG_SETTING_SOFT_LIMIT                                   :Maximum number of non-sticky windows: {STRING2}
 
STR_CONFIG_SETTING_SOFT_LIMIT_HELPTEXT                          :Number of non-sticky open windows before old windows get automatically closed to make room for new windows
 
STR_CONFIG_SETTING_SOFT_LIMIT_VALUE                             :{COMMA}
src/table/settings.ini
Show inline comments
 
@@ -2382,28 +2382,28 @@ def      = 1
 
min      = 1
 
max      = 5000
 
cat      = SC_BASIC
 

	
 
[SDT_VAR]
 
base     = GameSettings
 
var      = construction.extra_tree_placement
 
type     = SLE_UINT8
 
from     = SLV_132
 
guiflags = SGF_MULTISTRING
 
def      = 2
 
min      = 0
 
max      = 2
 
max      = 3
 
str      = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT
 
strhelp  = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_HELPTEXT
 
strval   = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NONE
 
strval   = STR_CONFIG_SETTING_EXTRA_TREE_PLACEMENT_NO_SPREAD
 
cat      = SC_BASIC
 

	
 
[SDT_VAR]
 
base     = GameSettings
 
var      = game_creation.custom_sea_level
 
type     = SLE_UINT8
 
from     = SLV_149
 
def      = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
 
min      = CUSTOM_SEA_LEVEL_MIN_PERCENTAGE
 
max      = CUSTOM_SEA_LEVEL_MAX_PERCENTAGE
 
cat      = SC_BASIC
 

	
src/tree_cmd.cpp
Show inline comments
 
@@ -33,27 +33,28 @@
 
 * List of tree placer algorithm.
 
 *
 
 * This enumeration defines all possible tree placer algorithm in the game.
 
 */
 
enum TreePlacer {
 
	TP_NONE,     ///< No tree placer algorithm
 
	TP_ORIGINAL, ///< The original algorithm
 
	TP_IMPROVED, ///< A 'improved' algorithm
 
};
 

	
 
/** Where to place trees while in-game? */
 
enum ExtraTreePlacement {
 
	ETP_NONE,       ///< Place trees on no tiles
 
	ETP_RAINFOREST, ///< Place trees only on rainforest tiles
 
	ETP_ALL,        ///< Place trees on all tiles
 
	ETP_NO_SPREAD,           ///< Grow trees on tiles that have them but don't spread to new ones
 
	ETP_SPREAD_RAINFOREST,   ///< Grow trees on tiles that have them, only spread to new ones in rainforests
 
	ETP_SPREAD_ALL,          ///< Grow trees and spread them without restrictions
 
	ETP_NO_GROWTH_NO_SPREAD, ///< Don't grow trees and don't spread them at all
 
};
 

	
 
/** Determines when to consider building more trees. */
 
byte _trees_tick_ctr;
 

	
 
static const uint16 DEFAULT_TREE_STEPS = 1000;             ///< Default number of attempts for placing trees.
 
static const uint16 DEFAULT_RAINFOREST_TREE_STEPS = 15000; ///< Default number of attempts for placing extra trees at rainforest in tropic.
 
static const uint16 EDITOR_TREE_DIV = 5;                   ///< Game editor tree generation divisor factor.
 

	
 
/**
 
 * Tests if a tile can be converted to MP_TREES
 
 * This is true for clear ground without farms or rocks.
 
@@ -626,26 +627,26 @@ static void TileLoopTreesAlps(TileIndex 
 
					SndPlayTileFx((r & 0x80000000) ? SND_39_HEAVY_WIND : SND_34_WIND, tile);
 
				}
 
			}
 
			return;
 
		}
 
	}
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
static bool CanPlantExtraTrees(TileIndex tile)
 
{
 
	return ((_settings_game.game_creation.landscape == LT_TROPIC && GetTropicZone(tile) == TROPICZONE_RAINFOREST) ?
 
		_settings_game.construction.extra_tree_placement != ETP_NONE :
 
		_settings_game.construction.extra_tree_placement == ETP_ALL);
 
		(_settings_game.construction.extra_tree_placement == ETP_SPREAD_ALL || _settings_game.construction.extra_tree_placement == ETP_SPREAD_RAINFOREST) :
 
		_settings_game.construction.extra_tree_placement == ETP_SPREAD_ALL);
 
}
 

	
 
static void TileLoop_Trees(TileIndex tile)
 
{
 
	if (GetTreeGround(tile) == TREE_GROUND_SHORE) {
 
		TileLoop_Water(tile);
 
	} else {
 
		switch (_settings_game.game_creation.landscape) {
 
			case LT_TROPIC: TileLoopTreesDesert(tile); break;
 
			case LT_ARCTIC: TileLoopTreesAlps(tile);   break;
 
		}
 
	}
 
@@ -653,24 +654,27 @@ static void TileLoop_Trees(TileIndex til
 
	AmbientSoundEffect(tile);
 

	
 
	uint treeCounter = GetTreeCounter(tile);
 

	
 
	/* Handle growth of grass (under trees/on MP_TREES tiles) at every 8th processings, like it's done for grass on MP_CLEAR tiles. */
 
	if ((treeCounter & 7) == 7 && GetTreeGround(tile) == TREE_GROUND_GRASS) {
 
		uint density = GetTreeDensity(tile);
 
		if (density < 3) {
 
			SetTreeGroundDensity(tile, TREE_GROUND_GRASS, density + 1);
 
			MarkTileDirtyByTile(tile);
 
		}
 
	}
 

	
 
	if (_settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
 

	
 
	if (GetTreeCounter(tile) < 15) {
 
		AddTreeCounter(tile, 1);
 
		return;
 
	}
 
	SetTreeCounter(tile, 0);
 

	
 
	switch (GetTreeGrowth(tile)) {
 
		case 3: // regular sized tree
 
			if (_settings_game.game_creation.landscape == LT_TROPIC &&
 
					GetTreeType(tile) != TREE_CACTUS &&
 
					GetTropicZone(tile) == TROPICZONE_DESERT) {
 
				AddTreeGrowth(tile, 1);
 
@@ -746,41 +750,41 @@ static void TileLoop_Trees(TileIndex til
 
			break;
 

	
 
		default:
 
			AddTreeGrowth(tile, 1);
 
			break;
 
	}
 

	
 
	MarkTileDirtyByTile(tile);
 
}
 

	
 
void OnTick_Trees()
 
{
 
	/* Don't place trees if that's not allowed */
 
	if (_settings_game.construction.extra_tree_placement == ETP_NONE) return;
 
	/* Don't spread trees if that's not allowed */
 
	if (_settings_game.construction.extra_tree_placement == ETP_NO_SPREAD || _settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return;
 

	
 
	uint32 r;
 
	TileIndex tile;
 
	TreeType tree;
 

	
 
	/* place a tree at a random rainforest spot */
 
	if (_settings_game.game_creation.landscape == LT_TROPIC &&
 
			(r = Random(), tile = RandomTileSeed(r), GetTropicZone(tile) == TROPICZONE_RAINFOREST) &&
 
			CanPlantTreesOnTile(tile, false) &&
 
			(tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 
		PlantTreesOnTile(tile, tree, 0, 0);
 
	}
 

	
 
	/* byte underflow */
 
	if (--_trees_tick_ctr != 0 || _settings_game.construction.extra_tree_placement != ETP_ALL) return;
 
	if (--_trees_tick_ctr != 0 || _settings_game.construction.extra_tree_placement == ETP_SPREAD_RAINFOREST) return;
 

	
 
	/* place a tree at a random spot */
 
	r = Random();
 
	tile = RandomTileSeed(r);
 
	if (CanPlantTreesOnTile(tile, false) && (tree = GetRandomTreeType(tile, GB(r, 24, 8))) != TREE_INVALID) {
 
		PlantTreesOnTile(tile, tree, 0, 0);
 
	}
 
}
 

	
 
static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
 
{
 
	return 0;
0 comments (0 inline, 0 general)