00001
00002
00005 #ifndef TREE_MAP_H
00006 #define TREE_MAP_H
00007
00019 enum TreeType {
00020 TREE_INVALID = -1,
00021 TREE_TEMPERATE = 0x00,
00022 TREE_SUB_ARCTIC = 0x0C,
00023 TREE_RAINFOREST = 0x14,
00024 TREE_CACTUS = 0x1B,
00025 TREE_SUB_TROPICAL = 0x1C,
00026 TREE_TOYLAND = 0x20,
00027 };
00028
00036 enum {
00037 TREE_COUNT_TEMPERATE = TREE_SUB_ARCTIC - TREE_TEMPERATE,
00038 TREE_COUNT_SUB_ARCTIC = TREE_RAINFOREST - TREE_SUB_ARCTIC,
00039 TREE_COUNT_RAINFOREST = TREE_CACTUS - TREE_RAINFOREST,
00040 TREE_COUNT_SUB_TROPICAL = TREE_SUB_TROPICAL - TREE_CACTUS,
00041 TREE_COUNT_TOYLAND = 9
00042 };
00043
00049 enum TreeGround {
00050 TREE_GROUND_GRASS = 0,
00051 TREE_GROUND_ROUGH = 1,
00052 TREE_GROUND_SNOW_DESERT = 2,
00053 TREE_GROUND_SHORE = 3,
00054 };
00055
00056
00069 static inline TreeType GetTreeType(TileIndex t)
00070 {
00071 assert(IsTileType(t, MP_TREES));
00072 return (TreeType)_m[t].m3;
00073 }
00074
00084 static inline TreeGround GetTreeGround(TileIndex t)
00085 {
00086 assert(IsTileType(t, MP_TREES));
00087 return (TreeGround)GB(_m[t].m2, 4, 2);
00088 }
00089
00109 static inline uint GetTreeDensity(TileIndex t)
00110 {
00111 assert(IsTileType(t, MP_TREES));
00112 return GB(_m[t].m2, 6, 2);
00113 }
00114
00126 static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
00127 {
00128 assert(IsTileType(t, MP_TREES));
00129 SB(_m[t].m2, 4, 2, g);
00130 SB(_m[t].m2, 6, 2, d);
00131 }
00132
00144 static inline uint GetTreeCount(TileIndex t)
00145 {
00146 assert(IsTileType(t, MP_TREES));
00147 return GB(_m[t].m5, 6, 2) + 1;
00148 }
00149
00161 static inline void AddTreeCount(TileIndex t, int c)
00162 {
00163 assert(IsTileType(t, MP_TREES));
00164 _m[t].m5 += c << 6;
00165 }
00166
00176 static inline uint GetTreeGrowth(TileIndex t)
00177 {
00178 assert(IsTileType(t, MP_TREES));
00179 return GB(_m[t].m5, 0, 3);
00180 }
00181
00191 static inline void AddTreeGrowth(TileIndex t, int a)
00192 {
00193 assert(IsTileType(t, MP_TREES));
00194 _m[t].m5 += a;
00195 }
00196
00207 static inline void SetTreeGrowth(TileIndex t, uint g)
00208 {
00209 assert(IsTileType(t, MP_TREES));
00210 SB(_m[t].m5, 0, 3, g);
00211 }
00212
00221 static inline uint GetTreeCounter(TileIndex t)
00222 {
00223 assert(IsTileType(t, MP_TREES));
00224 return GB(_m[t].m2, 0, 4);
00225 }
00226
00236 static inline void AddTreeCounter(TileIndex t, int a)
00237 {
00238 assert(IsTileType(t, MP_TREES));
00239 _m[t].m2 += a;
00240 }
00241
00251 static inline void SetTreeCounter(TileIndex t, uint c)
00252 {
00253 assert(IsTileType(t, MP_TREES));
00254 SB(_m[t].m2, 0, 4, c);
00255 }
00256
00269 static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
00270 {
00271 SetTileType(t, MP_TREES);
00272 SetTileOwner(t, OWNER_NONE);
00273 _m[t].m2 = density << 6 | ground << 4 | 0;
00274 _m[t].m3 = type;
00275 _m[t].m4 = 0 << 5 | 0 << 2;
00276 _m[t].m5 = count << 6 | growth;
00277 }
00278
00279 #endif