summaryrefslogtreecommitdiff
path: root/tree_map.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-30 09:29:01 +0000
committertron <tron@openttd.org>2006-03-30 09:29:01 +0000
commit7ad0d787e25306e700045cb678c66eeba9ea4434 (patch)
tree21b00e82b5c9850aa9567dba92d59ebb57aa50ba /tree_map.h
parent84de6477b2665dd0b16f93b677501dde02fc40d5 (diff)
downloadopenttd-7ad0d787e25306e700045cb678c66eeba9ea4434.tar.xz
(svn r4166) Sprinkle several map accessors with assert()s
Diffstat (limited to 'tree_map.h')
-rw-r--r--tree_map.h87
1 files changed, 74 insertions, 13 deletions
diff --git a/tree_map.h b/tree_map.h
index c53ad05e8..bc35b98b7 100644
--- a/tree_map.h
+++ b/tree_map.h
@@ -31,30 +31,91 @@ typedef enum TreeGround {
TR_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert
} TreeGround;
-static inline TreeType GetTreeType(TileIndex t) { return _m[t].m3; }
-static inline void SetTreeType(TileIndex t, TreeType r) { _m[t].m3 = r; }
-static inline TreeGround GetTreeGround(TileIndex t) { return GB(_m[t].m2, 4, 2); }
+static inline TreeType GetTreeType(TileIndex t)
+{
+ assert(IsTileType(t, MP_TREES));
+ return _m[t].m3;
+}
+
+
+static inline TreeGround GetTreeGround(TileIndex t)
+{
+ assert(IsTileType(t, MP_TREES));
+ return GB(_m[t].m2, 4, 2);
+}
+
+
+static inline uint GetTreeDensity(TileIndex t)
+{
+ assert(IsTileType(t, MP_TREES));
+ return GB(_m[t].m2, 6, 2);
+}
-static inline uint GetTreeDensity(TileIndex t) { return GB(_m[t].m2, 6, 2); }
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
{
+ assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m2, 4, 2, g);
SB(_m[t].m2, 6, 2, d);
}
-static inline void AddTreeCount(TileIndex t, int c) { _m[t].m5 += c << 6; }
-static inline uint GetTreeCount(TileIndex t) { return GB(_m[t].m5, 6, 2); }
-static inline void SetTreeCount(TileIndex t, uint c) { SB(_m[t].m5, 6, 2, c); }
-static inline void AddTreeGrowth(TileIndex t, int a) { _m[t].m5 += a; }
-static inline uint GetTreeGrowth(TileIndex t) { return GB(_m[t].m5, 0, 3); }
-static inline void SetTreeGrowth(TileIndex t, uint g) { SB(_m[t].m5, 0, 3, g); }
+static inline uint GetTreeCount(TileIndex t)
+{
+ assert(IsTileType(t, MP_TREES));
+ return GB(_m[t].m5, 6, 2);
+}
+
+static inline void AddTreeCount(TileIndex t, int c)
+{
+ assert(IsTileType(t, MP_TREES)); // XXX incomplete
+ _m[t].m5 += c << 6;
+}
+
+static inline void SetTreeCount(TileIndex t, uint c)
+{
+ assert(IsTileType(t, MP_TREES)); // XXX incomplete
+ SB(_m[t].m5, 6, 2, c);
+}
+
-static inline void AddTreeCounter(TileIndex t, int a) { _m[t].m2 += a; }
-static inline uint GetTreeCounter(TileIndex t) { return GB(_m[t].m2, 0, 4); }
-static inline void SetTreeCounter(TileIndex t, uint c) { SB(_m[t].m2, 0, 4, c); }
+static inline uint GetTreeGrowth(TileIndex t)
+{
+ assert(IsTileType(t, MP_TREES));
+ return GB(_m[t].m5, 0, 3);
+}
+
+static inline void AddTreeGrowth(TileIndex t, int a)
+{
+ assert(IsTileType(t, MP_TREES)); // XXX incomplete
+ _m[t].m5 += a;
+}
+
+static inline void SetTreeGrowth(TileIndex t, uint g)
+{
+ assert(IsTileType(t, MP_TREES)); // XXX incomplete
+ SB(_m[t].m5, 0, 3, g);
+}
+
+
+static inline uint GetTreeCounter(TileIndex t)
+{
+ assert(IsTileType(t, MP_TREES));
+ return GB(_m[t].m2, 0, 4);
+}
+
+static inline void AddTreeCounter(TileIndex t, int a)
+{
+ assert(IsTileType(t, MP_TREES)); // XXX incomplete
+ _m[t].m2 += a;
+}
+
+static inline void SetTreeCounter(TileIndex t, uint c)
+{
+ assert(IsTileType(t, MP_TREES)); // XXX incomplete
+ SB(_m[t].m2, 0, 4, c);
+}
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)