author | tron |
Sun, 05 Mar 2006 11:18:34 +0000 | |
changeset 3145 | 349b745dfbf4 |
parent 3144 | 426b825578f9 |
child 3369 | 00c2ca209a89 |
permissions | -rw-r--r-- |
2981 | 1 |
/* $Id$ */ |
2 |
||
3145
349b745dfbf4
(svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents:
3144
diff
changeset
|
3 |
#ifndef TREE_MAP_H |
349b745dfbf4
(svn r3765) Fix some naming glitches in r3763 and add missing svn properties
tron
parents:
3144
diff
changeset
|
4 |
#define TREE_MAP_H |
2981 | 5 |
|
6 |
#include "macros.h" |
|
7 |
||
8 |
typedef enum TreeType { |
|
9 |
TR_INVALID = -1, |
|
10 |
TR_TEMPERATE = 0, |
|
11 |
TR_SUB_ARCTIC = 12, |
|
12 |
TR_RAINFOREST = 20, |
|
13 |
TR_CACTUS = 27, |
|
14 |
TR_SUB_TROPICAL = 28, |
|
15 |
TR_TOYLAND = 32 |
|
16 |
} TreeType; |
|
17 |
||
18 |
enum { |
|
19 |
TR_COUNT_TEMPERATE = TR_SUB_ARCTIC - TR_TEMPERATE, |
|
20 |
TR_COUNT_SUB_ARCTIC = TR_RAINFOREST - TR_SUB_ARCTIC, |
|
21 |
TR_COUNT_RAINFOREST = TR_CACTUS - TR_RAINFOREST, |
|
22 |
TR_COUNT_SUB_TROPICAL = TR_SUB_TROPICAL - TR_CACTUS, |
|
23 |
TR_COUNT_TOYLAND = 9 |
|
24 |
}; |
|
25 |
||
26 |
/* ground type, m2 bits 4...5 |
|
27 |
* valid densities (bits 6...7) in comments after the enum */ |
|
28 |
typedef enum TreeGround { |
|
29 |
TR_GRASS = 0, // 0 |
|
30 |
TR_ROUGH = 1, // 0 |
|
31 |
TR_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert |
|
32 |
} TreeGround; |
|
33 |
||
34 |
static inline TreeType GetTreeType(TileIndex t) { return _m[t].m3; } |
|
35 |
static inline void SetTreeType(TileIndex t, TreeType r) { _m[t].m3 = r; } |
|
36 |
||
37 |
static inline TreeGround GetTreeGround(TileIndex t) { return GB(_m[t].m2, 4, 2); } |
|
38 |
||
39 |
static inline uint GetTreeDensity(TileIndex t) { return GB(_m[t].m2, 6, 2); } |
|
40 |
||
41 |
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d) |
|
42 |
{ |
|
43 |
SB(_m[t].m2, 4, 2, g); |
|
44 |
SB(_m[t].m2, 6, 2, d); |
|
45 |
} |
|
46 |
||
47 |
static inline void AddTreeCount(TileIndex t, int c) { _m[t].m5 += c << 6; } |
|
48 |
static inline uint GetTreeCount(TileIndex t) { return GB(_m[t].m5, 6, 2); } |
|
49 |
static inline void SetTreeCount(TileIndex t, uint c) { SB(_m[t].m5, 6, 2, c); } |
|
50 |
||
51 |
static inline void AddTreeGrowth(TileIndex t, int a) { _m[t].m5 += a; } |
|
52 |
static inline uint GetTreeGrowth(TileIndex t) { return GB(_m[t].m5, 0, 3); } |
|
53 |
static inline void SetTreeGrowth(TileIndex t, uint g) { SB(_m[t].m5, 0, 3, g); } |
|
54 |
||
55 |
static inline void AddTreeCounter(TileIndex t, int a) { _m[t].m2 += a; } |
|
56 |
static inline uint GetTreeCounter(TileIndex t) { return GB(_m[t].m2, 0, 4); } |
|
57 |
static inline void SetTreeCounter(TileIndex t, uint c) { SB(_m[t].m2, 0, 4, c); } |
|
58 |
||
3079
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
59 |
|
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
60 |
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density) |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
61 |
{ |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
62 |
SetTileType(t, MP_TREES); |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
63 |
SetTileOwner(t, OWNER_NONE); |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
64 |
_m[t].m2 = density << 6 | ground << 4 | 0; |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
65 |
_m[t].m3 = type; |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
66 |
_m[t].m4 = 0 << 5 | 0 << 2; |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
67 |
_m[t].m5 = count << 6 | growth; |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
68 |
} |
d6541c027250
(svn r3668) Add a function to turn a tile into a tree tile
tron
parents:
2981
diff
changeset
|
69 |
|
2981 | 70 |
#endif |