# tree_map.h File Reference

Map accessors for tree tiles. More...

`#include "tile_map.h"`

Go to the source code of this file.

## Enumerations
enum | TreeType { TREE_INVALID = -1, TREE_TEMPERATE = 0x00, TREE_SUB_ARCTIC = 0x0C, TREE_RAINFOREST = 0x14, TREE_CACTUS = 0x1B, TREE_SUB_TROPICAL = 0x1C, TREE_TOYLAND = 0x20 }
| List of tree types along all landscape types. More...
enum | { TREE_COUNT_TEMPERATE = TREE_SUB_ARCTIC - TREE_TEMPERATE, TREE_COUNT_SUB_ARCTIC = TREE_RAINFOREST - TREE_SUB_ARCTIC, TREE_COUNT_RAINFOREST = TREE_CACTUS - TREE_RAINFOREST, TREE_COUNT_SUB_TROPICAL = TREE_SUB_TROPICAL - TREE_CACTUS, TREE_COUNT_TOYLAND = 9 }
| Counts the number of treetypes for each landscape. More...
enum | TreeGround { TREE_GROUND_GRASS = 0, TREE_GROUND_ROUGH = 1, TREE_GROUND_SNOW_DESERT = 2, TREE_GROUND_SHORE = 3, TREE_GROUND_ROUGH_SNOW = 4 }
| Enumeration for ground types of tiles with trees. More...
## Functions
static TreeType | GetTreeType (TileIndex t)
| Returns the treetype of a tile.
static TreeGround | GetTreeGround (TileIndex t)
| Returns the groundtype for tree tiles.
static uint | GetTreeDensity (TileIndex t)
| Returns the 'density' of a tile with trees.
static void | SetTreeGroundDensity (TileIndex t, TreeGround g, uint d)
| Set the density and ground type of a tile with trees.
static uint | GetTreeCount (TileIndex t)
| Returns the number of trees on a tile.
static void | AddTreeCount (TileIndex t, int c)
| Add a amount to the tree-count value of a tile with trees.
static uint | GetTreeGrowth (TileIndex t)
| Returns the tree growth status.
static void | AddTreeGrowth (TileIndex t, int a)
| Add a value to the tree growth status.
static void | SetTreeGrowth (TileIndex t, uint g)
| Sets the tree growth status of a tile.
static uint | GetTreeCounter (TileIndex t)
| Get the tick counter of a tree tile.
static void | AddTreeCounter (TileIndex t, int a)
| Add a value on the tick counter of a tree-tile.
static void | SetTreeCounter (TileIndex t, uint c)
| Set the tick counter for a tree-tile.
static void | MakeTree (TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
| Make a tree-tile.

## Detailed Description

Map accessors for tree tiles.

Definition in file tree_map.h.

## Enumeration Type Documentation

anonymous enum

Counts the number of treetypes for each landscape.

This list contains the counts of different treetypes for each landscape. This list contains 5 entries instead of 4 (as there are only 4 landscape types) as the sub tropic landscape got two types of area, one for normal trees and one only for cacti.

Enumerator:

  TREE_COUNT_TEMPERATE | number of treetypes on a temperate map
  TREE_COUNT_SUB_ARCTIC | number of treetypes on a sub arctic map
  TREE_COUNT_RAINFOREST | number of treetypes for the 'green part' of a sub tropic map
  TREE_COUNT_SUB_TROPICAL | number of treetypes for the 'desert part' of a sub tropic map
  TREE_COUNT_TOYLAND | number of treetypes on a toyland map

Definition at line 45 of file tree_map.h.

enum TreeGround

Enumeration for ground types of tiles with trees.

This enumeration defines the ground types for tiles with trees on it.

Enumerator:

  TREE_GROUND_GRASS | normal grass
  TREE_GROUND_ROUGH | some rough tile
  TREE_GROUND_SNOW_DESERT | a desert or snow tile, depend on landscape
  TREE_GROUND_SHORE | shore
  TREE_GROUND_ROUGH_SNOW | a snow tile that is rough underneed

Definition at line 58 of file tree_map.h.

enum TreeType

List of tree types along all landscape types.

This enumeration contains a list of the different tree types along all landscape types. The values for the enumerations may be used for offsets from the grfs files. These points to the start of the tree list for a landscape. See the TREE_COUNT_* enumerations for the amount of different trees for a specific landscape.

Note:
  TREE_INVALID may be 0xFF according to the coding style, not -1 (Progman)

Enumerator:

  TREE_INVALID | An invalid tree.
  TREE_TEMPERATE | temperate tree
  TREE_SUB_ARCTIC | tree on a sub_arctic landscape
  TREE_RAINFOREST | tree on the 'green part' on a sub-tropical map
  TREE_CACTUS | a catus for the 'desert part' on a sub-tropical map
  TREE_SUB_TROPICAL | tree on a sub-tropical map, non-rainforest, non-desert
  TREE_TOYLAND | tree on a toyland map

Definition at line 28 of file tree_map.h.

## Function Documentation

static void AddTreeCount | ( | TileIndex | t,
|  | int | c |
| ) |  |  | `[inline, static]`

Add a amount to the tree-count value of a tile with trees.

This function add a value to the tree-count value of a tile. This value may be negative to reduce the tree-counter. If the resulting value reach 0 it doesn't get converted to a "normal" tile.

Parameters:

  | t | The tile to change the tree amount
  | c | The value to add (or reduce) on the tree-count value

Precondition:
  Tile must be of type MP_TREES

Definition at line 171 of file tree_map.h.

References _m, IsTileType(), Tile::m5, and MP_TREES.

Referenced by CmdPlantTree().

static void AddTreeCounter | ( | TileIndex | t,
|  | int | a |
| ) |  |  | `[inline, static]`

Add a value on the tick counter of a tree-tile.

This function adds a value on the tick counter of a tree-tile.

Parameters:

  | t | The tile to add the value on
  | a | The value to add on the tick counter

Precondition:
  Tile must be of type MP_TREES

Definition at line 246 of file tree_map.h.

References _m, IsTileType(), Tile::m2, and MP_TREES.

static void AddTreeGrowth | ( | TileIndex | t,
|  | int | a |
| ) |  |  | `[inline, static]`

Add a value to the tree growth status.

This function adds a value to the tree grow status of a tile.

Parameters:

  | t | The tile to add the value on
  | a | The value to add on the tree growth status

Precondition:
  Tile must be of type MP_TREES

Definition at line 201 of file tree_map.h.

References _m, IsTileType(), Tile::m5, and MP_TREES.

static uint GetTreeCount | ( | TileIndex | t | ) | `[inline, static]`

Returns the number of trees on a tile.

This function returns the number of trees of a tile (1-4). The tile must be contains at least one tree or be more specific: it must be of type MP_TREES.

Parameters:

  | t | The index to get the number of trees

Returns:
  The number of trees (1-4)

Precondition:
  Tile must be of type MP_TREES

Definition at line 154 of file tree_map.h.

References _m, GB(), IsTileType(), and MP_TREES.

Referenced by CmdPlantTree().

static uint GetTreeCounter | ( | TileIndex | t | ) | `[inline, static]`

Get the tick counter of a tree tile.

Returns the saved tick counter of a given tile.

Parameters:

  | t | The tile to get the counter value from

Precondition:
  Tile must be of type MP_TREES

Definition at line 231 of file tree_map.h.

References _m, GB(), IsTileType(), and MP_TREES.

static uint GetTreeDensity | ( | TileIndex | t | ) | `[inline, static]`

Returns the 'density' of a tile with trees.

This function returns the density of a tile which got trees. Note that this value doesn't count the number of trees on a tile, use GetTreeCount instead. This function instead returns some kind of groundtype of the tile. As the map-array is finite in size and the informations about the trees must be saved somehow other informations about a tile must be saved somewhere encoded in the tile. So this function returns the density of a tile for sub arctic and sub tropical games. This means for sub arctic the type of snowline (0 to 3 for all 4 types of snowtiles) and for sub tropical the value 3 for a desert (and 0 for non-desert). The functionname is not read as "get the tree density of a tile" but "get the density of a tile which got trees".

Parameters:

  | t | The tile to get the 'density'

Precondition:
  Tile must be of type MP_TREES

See also:
  GetTreeCount

Definition at line 119 of file tree_map.h.

References _m, GB(), IsTileType(), and MP_TREES.

static TreeGround GetTreeGround | ( | TileIndex | t | ) | `[inline, static]`

Returns the groundtype for tree tiles.

This function returns the groundtype of a tile with trees.

Parameters:

  | t | The tile to get the groundtype from

Returns:
  The groundtype of the tile

Precondition:
  Tile must be of type MP_TREES

Definition at line 94 of file tree_map.h.

References _m, GB(), IsTileType(), and MP_TREES.

Referenced by GenerateRockyArea(), GetFloodingBehaviour(), GetNearbyTileInformation(), GetSmallMapVegetationPixels(), AITile::IsCoastTile(), and PlaceTree().

static uint GetTreeGrowth | ( | TileIndex | t | ) | `[inline, static]`

Returns the tree growth status.

This function returns the tree growth status of a tile with trees.

Parameters:

  | t | The tile to get the tree growth status

Returns:
  The tree growth status

Precondition:
  Tile must be of type MP_TREES

Definition at line 186 of file tree_map.h.

References _m, GB(), IsTileType(), and MP_TREES.

Referenced by SearchLumberMillTrees().

static TreeType GetTreeType | ( | TileIndex | t | ) | `[inline, static]`

Returns the treetype of a tile.

This function returns the treetype of a given tile. As there are more possible treetypes for a tile in a game as the enumeration TreeType defines this function may be return a value which isn't catch by an entry of the enumeration TreeType. But there is no problem known about it.

Parameters:

  | t | The tile to get the treetype from

Returns:
  The treetype of the given tile with trees

Precondition:
  Tile t must be of type MP_TREES

Definition at line 79 of file tree_map.h.

References _m, IsTileType(), Tile::m3, and MP_TREES.

static void MakeTree | ( | TileIndex | t,
|  | TreeType | type,
|  | uint | count,
|  | uint | growth,
|  | TreeGround | ground,
|  | uint | density |
| ) |  |  | `[inline, static]`

Make a tree-tile.

This functions change the tile to a tile with trees and all informations which belongs to it.

Parameters:

  | t | The tile to make a tree-tile from
  | type | The type of the tree
  | count | the number of trees
  | growth | the growth status
  | ground | the ground type
  | density | the density (not the number of trees)

Definition at line 279 of file tree_map.h.

References _m, _me, Tile::m2, Tile::m3, Tile::m4, Tile::m5, TileExtended::m7, MP_TREES, OWNER_NONE, SB(), SetTileOwner(), and SetTileType().

Referenced by PlantTreesOnTile().

static void SetTreeCounter | ( | TileIndex | t,
|  | uint | c |
| ) |  |  | `[inline, static]`

Set the tick counter for a tree-tile.

This function sets directly the tick counter for a tree-tile.

Parameters:

  | t | The tile to set the tick counter
  | c | The new tick counter value

Precondition:
  Tile must be of type MP_TREES

Definition at line 261 of file tree_map.h.

References _m, IsTileType(), MP_TREES, and SB().

Referenced by PlaceTree().

static void SetTreeGroundDensity | ( | TileIndex | t,
|  | TreeGround | g,
|  | uint | d |
| ) |  |  | `[inline, static]`

Set the density and ground type of a tile with trees.

This functions saves the ground type and the density which belongs to it for a given tile.

Parameters:

  | t | The tile to set the density and ground type
  | g | The ground type to save
  | d | The density to save with

Precondition:
  Tile must be of type MP_TREES

Definition at line 136 of file tree_map.h.

References _m, IsTileType(), MP_TREES, and SB().

Referenced by DoDryUp(), DoFloodTile(), and PlaceTree().

static void SetTreeGrowth | ( | TileIndex | t,
|  | uint | g |
| ) |  |  | `[inline, static]`

Sets the tree growth status of a tile.

This function sets the tree growth status of a tile directly with the given value.

Parameters:

  | t | The tile to change the tree growth status
  | g | The new value

Precondition:
  Tile must be of type MP_TREES

Definition at line 217 of file tree_map.h.

References _m, IsTileType(), MP_TREES, and SB().