tree_map.h

Go to the documentation of this file.
00001 /* $Id: tree_map.h 17570 2009-09-19 09:51:14Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef TREE_MAP_H
00013 #define TREE_MAP_H
00014 
00026 enum TreeType {
00027   TREE_INVALID      = -1,   
00028   TREE_TEMPERATE    = 0x00, 
00029   TREE_SUB_ARCTIC   = 0x0C, 
00030   TREE_RAINFOREST   = 0x14, 
00031   TREE_CACTUS       = 0x1B, 
00032   TREE_SUB_TROPICAL = 0x1C, 
00033   TREE_TOYLAND      = 0x20, 
00034 };
00035 
00043 enum {
00044   TREE_COUNT_TEMPERATE    = TREE_SUB_ARCTIC   - TREE_TEMPERATE,  
00045   TREE_COUNT_SUB_ARCTIC   = TREE_RAINFOREST   - TREE_SUB_ARCTIC, 
00046   TREE_COUNT_RAINFOREST   = TREE_CACTUS       - TREE_RAINFOREST, 
00047   TREE_COUNT_SUB_TROPICAL = TREE_SUB_TROPICAL - TREE_CACTUS,     
00048   TREE_COUNT_TOYLAND      = 9                                    
00049 };
00050 
00056 enum TreeGround {
00057   TREE_GROUND_GRASS       = 0, 
00058   TREE_GROUND_ROUGH       = 1, 
00059   TREE_GROUND_SNOW_DESERT = 2, 
00060   TREE_GROUND_SHORE       = 3, 
00061 };
00062 
00063 
00076 static inline TreeType GetTreeType(TileIndex t)
00077 {
00078   assert(IsTileType(t, MP_TREES));
00079   return (TreeType)_m[t].m3;
00080 }
00081 
00091 static inline TreeGround GetTreeGround(TileIndex t)
00092 {
00093   assert(IsTileType(t, MP_TREES));
00094   return (TreeGround)GB(_m[t].m2, 4, 2);
00095 }
00096 
00116 static inline uint GetTreeDensity(TileIndex t)
00117 {
00118   assert(IsTileType(t, MP_TREES));
00119   return GB(_m[t].m2, 6, 2);
00120 }
00121 
00133 static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
00134 {
00135   assert(IsTileType(t, MP_TREES)); // XXX incomplete
00136   SB(_m[t].m2, 4, 2, g);
00137   SB(_m[t].m2, 6, 2, d);
00138 }
00139 
00151 static inline uint GetTreeCount(TileIndex t)
00152 {
00153   assert(IsTileType(t, MP_TREES));
00154   return GB(_m[t].m5, 6, 2) + 1;
00155 }
00156 
00168 static inline void AddTreeCount(TileIndex t, int c)
00169 {
00170   assert(IsTileType(t, MP_TREES)); // XXX incomplete
00171   _m[t].m5 += c << 6;
00172 }
00173 
00183 static inline uint GetTreeGrowth(TileIndex t)
00184 {
00185   assert(IsTileType(t, MP_TREES));
00186   return GB(_m[t].m5, 0, 3);
00187 }
00188 
00198 static inline void AddTreeGrowth(TileIndex t, int a)
00199 {
00200   assert(IsTileType(t, MP_TREES)); // XXX incomplete
00201   _m[t].m5 += a;
00202 }
00203 
00214 static inline void SetTreeGrowth(TileIndex t, uint g)
00215 {
00216   assert(IsTileType(t, MP_TREES)); // XXX incomplete
00217   SB(_m[t].m5, 0, 3, g);
00218 }
00219 
00228 static inline uint GetTreeCounter(TileIndex t)
00229 {
00230   assert(IsTileType(t, MP_TREES));
00231   return GB(_m[t].m2, 0, 4);
00232 }
00233 
00243 static inline void AddTreeCounter(TileIndex t, int a)
00244 {
00245   assert(IsTileType(t, MP_TREES)); // XXX incomplete
00246   _m[t].m2 += a;
00247 }
00248 
00258 static inline void SetTreeCounter(TileIndex t, uint c)
00259 {
00260   assert(IsTileType(t, MP_TREES)); // XXX incomplete
00261   SB(_m[t].m2, 0, 4, c);
00262 }
00263 
00276 static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
00277 {
00278   SetTileType(t, MP_TREES);
00279   SetTileOwner(t, OWNER_NONE);
00280   _m[t].m2 = density << 6 | ground << 4 | 0;
00281   _m[t].m3 = type;
00282   _m[t].m4 = 0 << 5 | 0 << 2;
00283   _m[t].m5 = count << 6 | growth;
00284   SB(_m[t].m6, 2, 4, 0);
00285   _me[t].m7 = 0;
00286 }
00287 
00288 #endif /* TREE_MAP_H */

Generated on Wed Dec 23 23:27:56 2009 for OpenTTD by  doxygen 1.5.6