tron@2981: /* $Id$ */ tron@2981: tron@3145: #ifndef TREE_MAP_H tron@3145: #define TREE_MAP_H tron@2981: tron@2981: #include "macros.h" tron@2981: tron@2981: typedef enum TreeType { tron@3441: TREE_INVALID = -1, tron@3441: TREE_TEMPERATE = 0, tron@3441: TREE_SUB_ARCTIC = 12, tron@3441: TREE_RAINFOREST = 20, tron@3441: TREE_CACTUS = 27, tron@3441: TREE_SUB_TROPICAL = 28, tron@3441: TREE_TOYLAND = 32 tron@2981: } TreeType; tron@2981: tron@2981: enum { tron@3441: TREE_COUNT_TEMPERATE = TREE_SUB_ARCTIC - TREE_TEMPERATE, tron@3441: TREE_COUNT_SUB_ARCTIC = TREE_RAINFOREST - TREE_SUB_ARCTIC, tron@3441: TREE_COUNT_RAINFOREST = TREE_CACTUS - TREE_RAINFOREST, tron@3441: TREE_COUNT_SUB_TROPICAL = TREE_SUB_TROPICAL - TREE_CACTUS, tron@3441: TREE_COUNT_TOYLAND = 9 tron@2981: }; tron@2981: tron@2981: /* ground type, m2 bits 4...5 tron@2981: * valid densities (bits 6...7) in comments after the enum */ tron@2981: typedef enum TreeGround { tron@3441: TREE_GROUND_GRASS = 0, // 0 tron@3441: TREE_GROUND_ROUGH = 1, // 0 tron@3441: TREE_GROUND_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert tron@2981: } TreeGround; tron@2981: tron@2981: tron@3369: static inline TreeType GetTreeType(TileIndex t) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); tron@3369: return _m[t].m3; tron@3369: } tron@2981: tron@3369: tron@3369: static inline TreeGround GetTreeGround(TileIndex t) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); tron@3369: return GB(_m[t].m2, 4, 2); tron@3369: } tron@3369: tron@3369: tron@3369: static inline uint GetTreeDensity(TileIndex t) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); tron@3369: return GB(_m[t].m2, 6, 2); tron@3369: } tron@3369: tron@2981: tron@2981: static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d) tron@2981: { tron@3369: assert(IsTileType(t, MP_TREES)); // XXX incomplete tron@2981: SB(_m[t].m2, 4, 2, g); tron@2981: SB(_m[t].m2, 6, 2, d); tron@2981: } tron@2981: tron@2981: tron@3369: static inline uint GetTreeCount(TileIndex t) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); tron@3369: return GB(_m[t].m5, 6, 2); tron@3369: } tron@2981: tron@3369: static inline void AddTreeCount(TileIndex t, int c) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); // XXX incomplete tron@3369: _m[t].m5 += c << 6; tron@3369: } tron@3369: tron@3369: static inline void SetTreeCount(TileIndex t, uint c) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); // XXX incomplete tron@3369: SB(_m[t].m5, 6, 2, c); tron@3369: } tron@3369: tron@3369: tron@3369: static inline uint GetTreeGrowth(TileIndex t) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); tron@3369: return GB(_m[t].m5, 0, 3); tron@3369: } tron@3369: tron@3369: static inline void AddTreeGrowth(TileIndex t, int a) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); // XXX incomplete tron@3369: _m[t].m5 += a; tron@3369: } tron@3369: tron@3369: static inline void SetTreeGrowth(TileIndex t, uint g) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); // XXX incomplete tron@3369: SB(_m[t].m5, 0, 3, g); tron@3369: } tron@3369: tron@3369: tron@3369: static inline uint GetTreeCounter(TileIndex t) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); tron@3369: return GB(_m[t].m2, 0, 4); tron@3369: } tron@3369: tron@3369: static inline void AddTreeCounter(TileIndex t, int a) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); // XXX incomplete tron@3369: _m[t].m2 += a; tron@3369: } tron@3369: tron@3369: static inline void SetTreeCounter(TileIndex t, uint c) tron@3369: { tron@3369: assert(IsTileType(t, MP_TREES)); // XXX incomplete tron@3369: SB(_m[t].m2, 0, 4, c); tron@3369: } tron@2981: tron@3079: tron@3079: static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density) tron@3079: { tron@3079: SetTileType(t, MP_TREES); tron@3079: SetTileOwner(t, OWNER_NONE); tron@3079: _m[t].m2 = density << 6 | ground << 4 | 0; tron@3079: _m[t].m3 = type; tron@3079: _m[t].m4 = 0 << 5 | 0 << 2; tron@3079: _m[t].m5 = count << 6 | growth; tron@3079: } tron@3079: peter1138@4666: #endif /* TREE_MAP_H */