author | peter1138 |
Tue, 07 Feb 2006 19:11:51 +0000 | |
changeset 2996 | 8087faf157d8 |
parent 2979 | 883788245931 |
child 3076 | 9584f34a83dc |
permissions | -rw-r--r-- |
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
2 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
3 |
#ifndef CLEAR_H |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
4 |
#define CLEAR_H |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
5 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
6 |
#include "macros.h" |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
7 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
8 |
/* ground type, m5 bits 2...4 |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
9 |
* valid densities (bits 0...1) in comments after the enum |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
10 |
*/ |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
11 |
typedef enum ClearGround { |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
12 |
CL_GRASS = 0, // 0-3 |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
13 |
CL_ROUGH = 1, // 3 |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
14 |
CL_ROCKS = 2, // 3 |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
15 |
CL_FIELDS = 3, // 3 |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
16 |
CL_SNOW = 4, // 0-3 |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
17 |
CL_DESERT = 5 // 1,3 |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
18 |
} ClearGround; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
19 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
20 |
static inline ClearGround GetClearGround(TileIndex t) { return GB(_m[t].m5, 2, 3); } |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
21 |
static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; } |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
22 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
23 |
static inline void AddClearDensity(TileIndex t, int d) { _m[t].m5 += d; } |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
24 |
static inline uint GetClearDensity(TileIndex t) { return GB(_m[t].m5, 0, 2); } |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
25 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
26 |
static inline void AddClearCounter(TileIndex t, int c) { _m[t].m5 += c << 5; } |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
27 |
static inline uint GetClearCounter(TileIndex t) { return GB(_m[t].m5, 5, 3); } |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
28 |
static inline void SetClearCounter(TileIndex t, uint c) { SB(_m[t].m5, 5, 3, c); } |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
29 |
|
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
30 |
/* Sets type and density in one go, also sets the counter to 0 */ |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
31 |
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density) |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
32 |
{ |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
33 |
_m[t].m5 = 0 << 5 | type << 2 | density; |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
34 |
} |
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
35 |
|
2979
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
36 |
static inline uint GetFieldType(TileIndex t) { return GB(_m[t].m3, 0, 4); } |
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
37 |
static inline void SetFieldType(TileIndex t, uint f) { SB(_m[t].m3, 0, 4, f); } |
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
38 |
|
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
39 |
/* Is used by tree tiles, too */ |
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
40 |
static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); } |
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
41 |
static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); } |
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
42 |
|
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
43 |
static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); } |
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
44 |
static inline void SetFenceSW(TileIndex t, uint h) { SB(_m[t].m4, 5, 3, h); } |
883788245931
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
45 |
|
2955
27221592ebbc
(svn r3514) -Codechange: Replace direct fiddling of bits for the ground type and density of clear tiles with symbolic names and accessors.
tron
parents:
diff
changeset
|
46 |
#endif |