author | tron |
Sun, 05 Mar 2006 10:19:33 +0000 | |
changeset 3144 | 33e42feae531 |
parent 3076 | clear.h@8b54ff8fa90a |
child 3145 | e833d7a78887 |
permissions | -rw-r--r-- |
2955
24de69e236d2
(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$ */ |
24de69e236d2
(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 |
|
24de69e236d2
(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 |
24de69e236d2
(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 |
24de69e236d2
(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 |
|
24de69e236d2
(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" |
3076
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
7 |
#include "tile.h" |
2955
24de69e236d2
(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 |
|
24de69e236d2
(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 |
/* ground type, m5 bits 2...4 |
24de69e236d2
(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 |
* valid densities (bits 0...1) in comments after the enum |
24de69e236d2
(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 |
*/ |
24de69e236d2
(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 |
typedef enum ClearGround { |
24de69e236d2
(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_GRASS = 0, // 0-3 |
24de69e236d2
(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_ROUGH = 1, // 3 |
24de69e236d2
(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_ROCKS = 2, // 3 |
24de69e236d2
(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_FIELDS = 3, // 3 |
24de69e236d2
(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_SNOW = 4, // 0-3 |
24de69e236d2
(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 |
CL_DESERT = 5 // 1,3 |
24de69e236d2
(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 |
} ClearGround; |
24de69e236d2
(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 |
|
24de69e236d2
(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 ClearGround GetClearGround(TileIndex t) { return GB(_m[t].m5, 2, 3); } |
24de69e236d2
(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 |
static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; } |
24de69e236d2
(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 |
|
24de69e236d2
(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 void AddClearDensity(TileIndex t, int d) { _m[t].m5 += d; } |
24de69e236d2
(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 |
static inline uint GetClearDensity(TileIndex t) { return GB(_m[t].m5, 0, 2); } |
24de69e236d2
(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 |
|
24de69e236d2
(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 void AddClearCounter(TileIndex t, int c) { _m[t].m5 += c << 5; } |
24de69e236d2
(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 uint GetClearCounter(TileIndex t) { return GB(_m[t].m5, 5, 3); } |
24de69e236d2
(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 |
static inline void SetClearCounter(TileIndex t, uint c) { SB(_m[t].m5, 5, 3, c); } |
24de69e236d2
(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 |
|
24de69e236d2
(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 |
/* Sets type and density in one go, also sets the counter to 0 */ |
24de69e236d2
(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 |
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density) |
24de69e236d2
(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 |
{ |
24de69e236d2
(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 |
_m[t].m5 = 0 << 5 | type << 2 | density; |
24de69e236d2
(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 |
} |
24de69e236d2
(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
|
36 |
|
2979
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
37 |
static inline uint GetFieldType(TileIndex t) { return GB(_m[t].m3, 0, 4); } |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
38 |
static inline void SetFieldType(TileIndex t, uint f) { SB(_m[t].m3, 0, 4, f); } |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
39 |
|
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
40 |
/* Is used by tree tiles, too */ |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
41 |
static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); } |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
42 |
static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); } |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
43 |
|
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
44 |
static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); } |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
45 |
static inline void SetFenceSW(TileIndex t, uint h) { SB(_m[t].m4, 5, 3, h); } |
3ddf7c78d469
(svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents:
2955
diff
changeset
|
46 |
|
3076
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
47 |
|
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
48 |
static inline void MakeClear(TileIndex t, ClearGround g, uint density) |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
49 |
{ |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
50 |
SetTileType(t, MP_CLEAR); |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
51 |
SetTileOwner(t, OWNER_NONE); |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
52 |
_m[t].m2 = 0; |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
53 |
_m[t].m3 = 0; |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
54 |
_m[t].m4 = 0 << 5 | 0 << 2; |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
55 |
_m[t].m5 = 0 << 5 | g << 2 | density; |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
56 |
} |
8b54ff8fa90a
(svn r3665) Add a function to turn a tile into a clear tile
tron
parents:
2979
diff
changeset
|
57 |
|
2955
24de69e236d2
(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
|
58 |
#endif |