src/tree_map.h
author rubidium
Thu, 29 May 2008 23:33:37 +0000
changeset 9425 fe15794c1448
parent 9111 48ce04029fe4
child 10363 96eb6897bf96
permissions -rw-r--r--
(svn r13339) -Feature: splitting of the main toolbar when the resolution becomes very low so the buttons are still visible and useable. Patch by Dominik.
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
     1
/* $Id$ */
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8459
diff changeset
     3
/** @file tree_map.h Map accessors for tree tiles. */
6422
6679df1c05ba (svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents: 6248
diff changeset
     4
3145
e833d7a78887 (svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents: 3144
diff changeset
     5
#ifndef TREE_MAP_H
e833d7a78887 (svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents: 3144
diff changeset
     6
#define TREE_MAP_H
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
     7
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
     8
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
     9
 * List of tree types along all landscape types.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    10
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    11
 * This enumeration contains a list of the different tree types along
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    12
 * all landscape types. The values for the enumerations may be used for
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    13
 * offsets from the grfs files. These points to the start of
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    14
 * the tree list for a landscape. See the TREE_COUNT_* enumerations
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    15
 * for the amount of different trees for a specific landscape.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    16
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    17
 * @note TREE_INVALID may be 0xFF according to the coding style, not -1 (Progman)
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    18
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5587
diff changeset
    19
enum TreeType {
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    20
	TREE_INVALID      = -1,   ///< An invalid tree
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    21
	TREE_TEMPERATE    = 0x00, ///< temperate tree
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    22
	TREE_SUB_ARCTIC   = 0x0C, ///< tree on a sub_arctic landscape
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    23
	TREE_RAINFOREST   = 0x14, ///< tree on the 'green part' on a sub-tropical map
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    24
	TREE_CACTUS       = 0x1B, ///< a catus for the 'desert part' on a sub-tropical map
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    25
	TREE_SUB_TROPICAL = 0x1C, ///< tree on a sub-tropical map, non-rainforest, non-desert
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    26
	TREE_TOYLAND      = 0x20, ///< tree on a toyland map
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5587
diff changeset
    27
};
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
    28
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    29
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    30
 * Counts the number of treetypes for each landscape.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    31
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    32
 * This list contains the counts of different treetypes for each landscape. This list contains
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    33
 * 5 entries instead of 4 (as there are only 4 landscape types) as the sub tropic landscape
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    34
 * got two types of area, one for normal trees and one only for cacti.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    35
 */
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
    36
enum {
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    37
	TREE_COUNT_TEMPERATE    = TREE_SUB_ARCTIC   - TREE_TEMPERATE,  ///< number of treetypes on a temperate map
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    38
	TREE_COUNT_SUB_ARCTIC   = TREE_RAINFOREST   - TREE_SUB_ARCTIC, ///< number of treetypes on a sub arctic map
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    39
	TREE_COUNT_RAINFOREST   = TREE_CACTUS       - TREE_RAINFOREST, ///< number of treetypes for the 'green part' of a sub tropic map
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    40
	TREE_COUNT_SUB_TROPICAL = TREE_SUB_TROPICAL - TREE_CACTUS,     ///< number of treetypes for the 'desert part' of a sub tropic map
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    41
	TREE_COUNT_TOYLAND      = 9                                    ///< number of treetypes on a toyland map
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
    42
};
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
    43
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    44
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    45
 * Enumeration for ground types of tiles with trees.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    46
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    47
 * This enumeration defines the ground types for tiles with trees on it.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    48
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5587
diff changeset
    49
enum TreeGround {
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    50
	TREE_GROUND_GRASS       = 0, ///< normal grass
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    51
	TREE_GROUND_ROUGH       = 1, ///< some rough tile
8459
86e0352eb993 (svn r12029) -Feature: Allow trees on shore.
frosch
parents: 8113
diff changeset
    52
	TREE_GROUND_SNOW_DESERT = 2, ///< a desert or snow tile, depend on landscape
86e0352eb993 (svn r12029) -Feature: Allow trees on shore.
frosch
parents: 8113
diff changeset
    53
	TREE_GROUND_SHORE       = 3, ///< shore
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 5587
diff changeset
    54
};
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
    55
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
    56
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    57
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    58
 * Returns the treetype of a tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    59
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    60
 * This function returns the treetype of a given tile. As there are more
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    61
 * possible treetypes for a tile in a game as the enumeration #TreeType defines
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    62
 * this function may be return a value which isn't catch by an entry of the
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    63
 * enumeration #TreeType. But there is no problem known about it.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    64
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    65
 * @param t The tile to get the treetype from
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    66
 * @return The treetype of the given tile with trees
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    67
 * @pre Tile t must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    68
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    69
static inline TreeType GetTreeType(TileIndex t)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    70
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    71
	assert(IsTileType(t, MP_TREES));
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    72
	return (TreeType)_m[t].m3;
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    73
}
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
    74
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    75
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    76
 * Returns the groundtype for tree tiles.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    77
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    78
 * This function returns the groundtype of a tile with trees.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    79
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    80
 * @param t The tile to get the groundtype from
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    81
 * @return The groundtype of the tile
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    82
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    83
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    84
static inline TreeGround GetTreeGround(TileIndex t)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    85
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    86
	assert(IsTileType(t, MP_TREES));
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
    87
	return (TreeGround)GB(_m[t].m2, 4, 2);
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    88
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
    89
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    90
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    91
 * Returns the 'density' of a tile with trees.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    92
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    93
 * This function returns the density of a tile which got trees. Note
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    94
 * that this value doesn't count the number of trees on a tile, use
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    95
 * #GetTreeCount instead. This function instead returns some kind of
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    96
 * groundtype of the tile. As the map-array is finite in size and
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    97
 * the informations about the trees must be saved somehow other
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    98
 * informations about a tile must be saved somewhere encoded in the
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
    99
 * tile. So this function returns the density of a tile for sub arctic
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   100
 * and sub tropical games. This means for sub arctic the type of snowline
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   101
 * (0 to 3 for all 4 types of snowtiles) and for sub tropical the value
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   102
 * 3 for a desert (and 0 for non-desert). The functionname is not read as
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   103
 * "get the tree density of a tile" but "get the density of a tile which got trees".
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   104
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   105
 * @param t The tile to get the 'density'
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   106
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   107
 * @see GetTreeCount
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   108
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   109
static inline uint GetTreeDensity(TileIndex t)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   110
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   111
	assert(IsTileType(t, MP_TREES));
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   112
	return GB(_m[t].m2, 6, 2);
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   113
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   114
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   115
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   116
 * Set the density and ground type of a tile with trees.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   117
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   118
 * This functions saves the ground type and the density which belongs to it
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   119
 * for a given tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   120
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   121
 * @param t The tile to set the density and ground type
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   122
 * @param g The ground type to save
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   123
 * @param d The density to save with
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   124
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   125
 */
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   126
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   127
{
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   128
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   129
	SB(_m[t].m2, 4, 2, g);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   130
	SB(_m[t].m2, 6, 2, d);
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   131
}
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   132
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   133
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   134
 * Returns the number of trees on a tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   135
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   136
 * This function returns the number of trees of a tile (1-4).
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   137
 * The tile must be contains at least one tree or be more specific: it must be
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   138
 * of type MP_TREES.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   139
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   140
 * @param t The index to get the number of trees
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   141
 * @return The number of trees (1-4)
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   142
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   143
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   144
static inline uint GetTreeCount(TileIndex t)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   145
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   146
	assert(IsTileType(t, MP_TREES));
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   147
	return GB(_m[t].m5, 6, 2);
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   148
}
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   149
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   150
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   151
 * Add a amount to the tree-count value of a tile with trees.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   152
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   153
 * This function add a value to the tree-count value of a tile. This
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   154
 * value may be negative to reduce the tree-counter. If the resulting
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   155
 * value reach 0 it doesn't get converted to a "normal" tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   156
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   157
 * @param t The tile to change the tree amount
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   158
 * @param c The value to add (or reduce) on the tree-count value
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   159
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   160
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   161
static inline void AddTreeCount(TileIndex t, int c)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   162
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   163
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   164
	_m[t].m5 += c << 6;
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   165
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   166
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   167
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   168
 * Sets the tree amount of a tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   169
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   170
 * This function directly sets the amount of trees of a tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   171
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   172
 * @param t The tile to set the amount of trees
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   173
 * @param c The number of trees
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   174
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   175
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   176
static inline void SetTreeCount(TileIndex t, uint c)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   177
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   178
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   179
	SB(_m[t].m5, 6, 2, c);
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   180
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   181
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   182
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   183
 * Returns the tree growth status.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   184
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   185
 * This function returns the tree growth status of a tile with trees.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   186
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   187
 * @param t The tile to get the tree growth status
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   188
 * @return The tree growth status
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   189
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   190
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   191
static inline uint GetTreeGrowth(TileIndex t)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   192
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   193
	assert(IsTileType(t, MP_TREES));
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   194
	return GB(_m[t].m5, 0, 3);
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   195
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   196
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   197
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   198
 * Add a value to the tree growth status.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   199
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   200
 * This function adds a value to the tree grow status of a tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   201
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   202
 * @param t The tile to add the value on
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   203
 * @param a The value to add on the tree growth status
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   204
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   205
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   206
static inline void AddTreeGrowth(TileIndex t, int a)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   207
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   208
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   209
	_m[t].m5 += a;
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   210
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   211
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   212
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   213
 * Sets the tree growth status of a tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   214
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   215
 * This function sets the tree growth status of a tile directly with
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   216
 * the given value.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   217
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   218
 * @param t The tile to change the tree growth status
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   219
 * @param g The new value
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   220
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   221
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   222
static inline void SetTreeGrowth(TileIndex t, uint g)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   223
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   224
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   225
	SB(_m[t].m5, 0, 3, g);
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   226
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   227
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   228
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   229
 * Get the tick counter of a tree tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   230
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   231
 * Returns the saved tick counter of a given tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   232
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   233
 * @param t The tile to get the counter value from
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   234
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   235
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   236
static inline uint GetTreeCounter(TileIndex t)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   237
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   238
	assert(IsTileType(t, MP_TREES));
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   239
	return GB(_m[t].m2, 0, 4);
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   240
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   241
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   242
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   243
 * Add a value on the tick counter of a tree-tile
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   244
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   245
 * This function adds a value on the tick counter of a tree-tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   246
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   247
 * @param t The tile to add the value on
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   248
 * @param a The value to add on the tick counter
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   249
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   250
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   251
static inline void AddTreeCounter(TileIndex t, int a)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   252
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   253
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   254
	_m[t].m2 += a;
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   255
}
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   256
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   257
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   258
 * Set the tick counter for a tree-tile
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   259
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   260
 * This function sets directly the tick counter for a tree-tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   261
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   262
 * @param t The tile to set the tick counter
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   263
 * @param c The new tick counter value
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   264
 * @pre Tile must be of type MP_TREES
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   265
 */
3369
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   266
static inline void SetTreeCounter(TileIndex t, uint c)
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   267
{
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   268
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   269
	SB(_m[t].m2, 0, 4, c);
cab209754317 (svn r4166) Sprinkle several map accessors with assert()s
tron
parents: 3145
diff changeset
   270
}
2981
ca5959cf9fc7 (svn r3556) Add accessors for handling tree tiles
tron
parents:
diff changeset
   271
7597
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   272
/**
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   273
 * Make a tree-tile.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   274
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   275
 * This functions change the tile to a tile with trees and all informations which belongs to it.
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   276
 *
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   277
 * @param t The tile to make a tree-tile from
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   278
 * @param type The type of the tree
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   279
 * @param set the number of trees
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   280
 * @param growth the growth status
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   281
 * @param ground the ground type
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   282
 * @param density the density (not the number of trees)
e9ad1ed5c4d5 (svn r11124) -Documentation: of tree_map.h and tree_cmd.cpp. Patch by Progman.
rubidium
parents: 6422
diff changeset
   283
 */
3079
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   284
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   285
{
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   286
	SetTileType(t, MP_TREES);
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   287
	SetTileOwner(t, OWNER_NONE);
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   288
	_m[t].m2 = density << 6 | ground << 4 | 0;
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   289
	_m[t].m3 = type;
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   290
	_m[t].m4 = 0 << 5 | 0 << 2;
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   291
	_m[t].m5 = count << 6 | growth;
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   292
}
a26f87fba4c1 (svn r3668) Add a function to turn a tile into a tree tile
tron
parents: 2981
diff changeset
   293
4666
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 3441
diff changeset
   294
#endif /* TREE_MAP_H */