# tree_map.h

Go to the documentation of this file.

    00001 /* $Id: tree_map.h 12029 2008-01-31 17:54:13Z frosch $ */
    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)); // XXX incomplete
    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);
    00148 }
    00149
    00161 static inline void AddTreeCount(TileIndex t, int c)
    00162 {
    00163   assert(IsTileType(t, MP_TREES)); // XXX incomplete
    00164   _m[t].m5 += c << 6;
    00165 }
    00166
    00176 static inline void SetTreeCount(TileIndex t, uint c)
    00177 {
    00178   assert(IsTileType(t, MP_TREES)); // XXX incomplete
    00179   SB(_m[t].m5, 6, 2, c);
    00180 }
    00181
    00191 static inline uint GetTreeGrowth(TileIndex t)
    00192 {
    00193   assert(IsTileType(t, MP_TREES));
    00194   return GB(_m[t].m5, 0, 3);
    00195 }
    00196
    00206 static inline void AddTreeGrowth(TileIndex t, int a)
    00207 {
    00208   assert(IsTileType(t, MP_TREES)); // XXX incomplete
    00209   _m[t].m5 += a;
    00210 }
    00211
    00222 static inline void SetTreeGrowth(TileIndex t, uint g)
    00223 {
    00224   assert(IsTileType(t, MP_TREES)); // XXX incomplete
    00225   SB(_m[t].m5, 0, 3, g);
    00226 }
    00227
    00236 static inline uint GetTreeCounter(TileIndex t)
    00237 {
    00238   assert(IsTileType(t, MP_TREES));
    00239   return GB(_m[t].m2, 0, 4);
    00240 }
    00241
    00251 static inline void AddTreeCounter(TileIndex t, int a)
    00252 {
    00253   assert(IsTileType(t, MP_TREES)); // XXX incomplete
    00254   _m[t].m2 += a;
    00255 }
    00256
    00266 static inline void SetTreeCounter(TileIndex t, uint c)
    00267 {
    00268   assert(IsTileType(t, MP_TREES)); // XXX incomplete
    00269   SB(_m[t].m2, 0, 4, c);
    00270 }
    00271
    00284 static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
    00285 {
    00286   SetTileType(t, MP_TREES);
    00287   SetTileOwner(t, OWNER_NONE);
    00288   _m[t].m2 = density << 6 | ground << 4 | 0;
    00289   _m[t].m3 = type;
    00290   _m[t].m4 = 0 << 5 | 0 << 2;
    00291   _m[t].m5 = count << 6 | growth;
    00292 }
    00293
    00294 #endif /* TREE_MAP_H */