Files
@ r19372:42adb924a732
Branch filter:
Location: cpp/openttd-patchpack/source/src/tree_map.h - annotation
r19372:42adb924a732
9.3 KiB
text/x-c
(svn r24287) -Feature [FS#2688]: News item for exclusive transport rights. (based on patch by Grantovich)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 | r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r12768:980ae0491352 r9111:983de9c5a848 r6422:5983361e241a r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r14248:a9050881acd7 r14248:a9050881acd7 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r6248:b940b09d7ab8 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r15009:8390f54dffd4 r6248:b940b09d7ab8 r5475:3f5cd13d1b63 r15594:ba7e42fbae24 r7597:3cfdcd268e1c r15594:ba7e42fbae24 r7597:3cfdcd268e1c r15264:ccfbc4196c34 r7597:3cfdcd268e1c r15594:ba7e42fbae24 r15594:ba7e42fbae24 r15594:ba7e42fbae24 r15594:ba7e42fbae24 r15594:ba7e42fbae24 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r6248:b940b09d7ab8 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r8459:1ef090778f87 r8459:1ef090778f87 r14813:2dc255bde71a r6248:b940b09d7ab8 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5587:034e5e185dc2 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r14161:b62f02f583d3 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r14161:b62f02f583d3 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r14161:b62f02f583d3 r14161:b62f02f583d3 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r10363:2000eaad8f5e r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r13060:e57594b0ca84 r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r7597:3cfdcd268e1c r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r14161:b62f02f583d3 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r11289:7e06e1b4e52d r11289:7e06e1b4e52d r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 r5475:3f5cd13d1b63 | /* $Id$ */
/*
* This file is part of OpenTTD.
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file tree_map.h Map accessors for tree tiles. */
#ifndef TREE_MAP_H
#define TREE_MAP_H
#include "tile_map.h"
/**
* 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.
*/
enum TreeType {
TREE_TEMPERATE = 0x00, ///< temperate tree
TREE_SUB_ARCTIC = 0x0C, ///< tree on a sub_arctic landscape
TREE_RAINFOREST = 0x14, ///< tree on the 'green part' on a sub-tropical map
TREE_CACTUS = 0x1B, ///< a catus for the 'desert part' on a sub-tropical map
TREE_SUB_TROPICAL = 0x1C, ///< tree on a sub-tropical map, non-rainforest, non-desert
TREE_TOYLAND = 0x20, ///< tree on a toyland map
TREE_INVALID = 0xFF, ///< An invalid tree
};
/* Counts the number of tree types for each landscape.
*
* This list contains the counts of different tree types for each landscape. This list contains
* 5 entries instead of 4 (as there are only 4 landscape types) as the sub tropic landscape
* has two types of area, one for normal trees and one only for cacti.
*/
static const uint TREE_COUNT_TEMPERATE = TREE_SUB_ARCTIC - TREE_TEMPERATE; ///< number of tree types on a temperate map.
static const uint TREE_COUNT_SUB_ARCTIC = TREE_RAINFOREST - TREE_SUB_ARCTIC; ///< number of tree types on a sub arctic map.
static const uint TREE_COUNT_RAINFOREST = TREE_CACTUS - TREE_RAINFOREST; ///< number of tree types for the 'rainforest part' of a sub-tropic map.
static const uint TREE_COUNT_SUB_TROPICAL = TREE_TOYLAND - TREE_SUB_TROPICAL; ///< number of tree types for the 'sub-tropic part' of a sub-tropic map.
static const uint TREE_COUNT_TOYLAND = 9; ///< number of tree types on a toyland map.
/**
* Enumeration for ground types of tiles with trees.
*
* This enumeration defines the ground types for tiles with trees on it.
*/
enum TreeGround {
TREE_GROUND_GRASS = 0, ///< normal grass
TREE_GROUND_ROUGH = 1, ///< some rough tile
TREE_GROUND_SNOW_DESERT = 2, ///< a desert or snow tile, depend on landscape
TREE_GROUND_SHORE = 3, ///< shore
TREE_GROUND_ROUGH_SNOW = 4, ///< A snow tile that is rough underneath.
};
/**
* 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.
*
* @param t The tile to get the treetype from
* @return The treetype of the given tile with trees
* @pre Tile t must be of type MP_TREES
*/
static inline TreeType GetTreeType(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return (TreeType)_m[t].m3;
}
/**
* Returns the groundtype for tree tiles.
*
* This function returns the groundtype of a tile with trees.
*
* @param t The tile to get the groundtype from
* @return The groundtype of the tile
* @pre Tile must be of type MP_TREES
*/
static inline TreeGround GetTreeGround(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return (TreeGround)GB(_m[t].m2, 6, 3);
}
/**
* 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".
*
* @param t The tile to get the 'density'
* @pre Tile must be of type MP_TREES
* @see GetTreeCount
*/
static inline uint GetTreeDensity(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m2, 4, 2);
}
/**
* 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.
*
* @param t The tile to set the density and ground type
* @param g The ground type to save
* @param d The density to save with
* @pre Tile must be of type MP_TREES
*/
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m2, 4, 2, d);
SB(_m[t].m2, 6, 3, g);
}
/**
* 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.
*
* @param t The index to get the number of trees
* @return The number of trees (1-4)
* @pre Tile must be of type MP_TREES
*/
static inline uint GetTreeCount(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m5, 6, 2) + 1;
}
/**
* 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.
*
* @param t The tile to change the tree amount
* @param c The value to add (or reduce) on the tree-count value
* @pre Tile must be of type MP_TREES
*/
static inline void AddTreeCount(TileIndex t, int c)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m5 += c << 6;
}
/**
* Returns the tree growth status.
*
* This function returns the tree growth status of a tile with trees.
*
* @param t The tile to get the tree growth status
* @return The tree growth status
* @pre Tile must be of type MP_TREES
*/
static inline uint GetTreeGrowth(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m5, 0, 3);
}
/**
* Add a value to the tree growth status.
*
* This function adds a value to the tree grow status of a tile.
*
* @param t The tile to add the value on
* @param a The value to add on the tree growth status
* @pre Tile must be of type MP_TREES
*/
static inline void AddTreeGrowth(TileIndex t, int a)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m5 += a;
}
/**
* Sets the tree growth status of a tile.
*
* This function sets the tree growth status of a tile directly with
* the given value.
*
* @param t The tile to change the tree growth status
* @param g The new value
* @pre Tile must be of type MP_TREES
*/
static inline void SetTreeGrowth(TileIndex t, uint g)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m5, 0, 3, g);
}
/**
* Get the tick counter of a tree tile.
*
* Returns the saved tick counter of a given tile.
*
* @param t The tile to get the counter value from
* @pre Tile must be of type MP_TREES
*/
static inline uint GetTreeCounter(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m2, 0, 4);
}
/**
* Add a value on the tick counter of a tree-tile
*
* This function adds a value on the tick counter of a tree-tile.
*
* @param t The tile to add the value on
* @param a The value to add on the tick counter
* @pre Tile must be of type MP_TREES
*/
static inline void AddTreeCounter(TileIndex t, int a)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m2 += a;
}
/**
* Set the tick counter for a tree-tile
*
* This function sets directly the tick counter for a tree-tile.
*
* @param t The tile to set the tick counter
* @param c The new tick counter value
* @pre Tile must be of type MP_TREES
*/
static inline void SetTreeCounter(TileIndex t, uint c)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m2, 0, 4, c);
}
/**
* Make a tree-tile.
*
* This functions change the tile to a tile with trees and all informations which belongs to it.
*
* @param t The tile to make a tree-tile from
* @param type The type of the tree
* @param count the number of trees
* @param growth the growth status
* @param ground the ground type
* @param density the density (not the number of trees)
*/
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
{
SetTileType(t, MP_TREES);
SetTileOwner(t, OWNER_NONE);
_m[t].m2 = ground << 6 | density << 4 | 0;
_m[t].m3 = type;
_m[t].m4 = 0 << 5 | 0 << 2;
_m[t].m5 = count << 6 | growth;
SB(_m[t].m6, 2, 4, 0);
_me[t].m7 = 0;
}
#endif /* TREE_MAP_H */
|