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
 
@@ -1617,15 +1617,16 @@ STR_CONFIG_SETTING_TOWN_CARGOGENMODE    
 
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}
src/table/settings.ini
Show inline comments
 
@@ -2388,16 +2388,16 @@ 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
src/tree_cmd.cpp
Show inline comments
 
@@ -39,15 +39,16 @@ enum TreePlacer {
 
	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.
 
@@ -632,14 +633,14 @@ static void TileLoopTreesAlps(TileIndex 
 
	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);
 
@@ -659,12 +660,15 @@ static void TileLoop_Trees(TileIndex til
 
		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);
 

	
 
@@ -752,14 +756,14 @@ static void TileLoop_Trees(TileIndex til
 

	
 
	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 */
 
@@ -768,13 +772,13 @@ void OnTick_Trees()
 
			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);
0 comments (0 inline, 0 general)