OpenTTD Source 20251213-master-g1091fa6071
tree_cmd.h File Reference

Command definitions related to tree tiles. More...

#include "command_type.h"

Go to the source code of this file.

Functions

void PlaceTree (TileIndex tile, uint32_t r, bool keep_density=false)
 Make a random tree tile of the given tile.
 
CommandCost CmdPlantTree (DoCommandFlags flags, TileIndex tile, TileIndex start_tile, uint8_t tree_to_plant, bool diagonal)
 Plant a tree.
 

Detailed Description

Command definitions related to tree tiles.

Definition in file tree_cmd.h.

Function Documentation

◆ CmdPlantTree()

CommandCost CmdPlantTree ( DoCommandFlags  flags,
TileIndex  tile,
TileIndex  start_tile,
uint8_t  tree_to_plant,
bool  diagonal 
)

Plant a tree.

Parameters
flagstype of operation
tileend tile of area-drag
start_tilestart tile of area-drag of tree plantation
tree_to_planttree type, TREE_INVALID means random.
diagonalWhether to use the Orthogonal (false) or Diagonal (true) iterator.
Returns
the cost of this operation or an error

Definition at line 504 of file tree_cmd.cpp.

References _current_company, _settings_game, CommandCost::AddCost(), AddTreeCount(), ChangeTownRating(), CLEAR_FIELDS, CLEAR_ROCKS, ClosestTownFromTile(), CMD_ERROR, TileIterator::Create(), EconomySettings::dist_local_authority, GameSettings::economy, Execute, EXPENSES_OTHER, CommandCost::Failed(), GameSettings::game_creation, GB(), GetClearGround(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), GetRandomTreeType(), GetTileSlope(), GetTileType(), GetTreeCount(), GetTropicZone(), Growing1, Grown, INVALID_STRING_ID, INVALID_TILE, IsBridgeAbove(), IsCoast(), IsInsideBS(), IsInsideMM(), IsSlopeWithOneCornerRaised(), IsTileType(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), GameCreationSettings::landscape, MarkTileDirtyByTile(), MP_CLEAR, MP_TREES, MP_WATER, PlantTreesOnTile(), Random, SetTropicZone(), Map::Size(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), to_underlying(), TREE_CACTUS, TREE_INVALID, CompanyProperties::tree_limit, TREE_RAINFOREST, TREE_SUB_TROPICAL, TREE_TOYLAND, TROPICZONE_DESERT, TROPICZONE_NORMAL, and TROPICZONE_RAINFOREST.

◆ PlaceTree()

void PlaceTree ( TileIndex  tile,
uint32_t  r,
bool  keep_density 
)

Make a random tree tile of the given tile.

Create a new tree-tile for the given tile. The second parameter is used for randomness like type and number of trees.

Parameters
tileThe tile to make a tree-tile from
rThe randomness value from a Random() value
keep_densityWhether to keep the existing ground density of the tile.

Definition at line 161 of file tree_cmd.cpp.

References GB(), GetRandomTreeType(), GetTreeGround(), MarkTileDirtyByTile(), PlantTreesOnTile(), SetTreeGroundDensity(), TREE_GROUND_ROUGH_SNOW, TREE_GROUND_SHORE, TREE_GROUND_SNOW_DESERT, and TREE_INVALID.

Referenced by MakeWetlands(), PlaceTreeAtSameHeight(), PlaceTreeGroups(), and PlaceTreesRandomly().