clear.h
author Darkvater
Mon, 20 Feb 2006 19:42:39 +0000
changeset 3046 baa216f9911a
parent 2979 3ddf7c78d469
child 3076 8b54ff8fa90a
permissions -rw-r--r--
(svn r3626) - Merge the SlGlobVarList (global variables) and SaveLoad (offset in struct, variable determined runtime) structs. The only difference between these two is the last element that either holds the address or the offset in the struct. Which one to take is determined by which function is called; SlObject or SlGlobList.
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"
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
     7
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
/* 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
     9
 * 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
    10
 */
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
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
    12
	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
    13
	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
    14
	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
    15
	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
    16
	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
    17
	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
    18
} 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
    19
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
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
    21
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
    22
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
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
    24
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
    25
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
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
    27
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
    28
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
    29
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
/* 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
    31
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
    32
{
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
	_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
    34
}
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
2979
3ddf7c78d469 (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); }
3ddf7c78d469 (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); }
3ddf7c78d469 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    38
3ddf7c78d469 (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 */
3ddf7c78d469 (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); }
3ddf7c78d469 (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); }
3ddf7c78d469 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    42
3ddf7c78d469 (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); }
3ddf7c78d469 (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); }
3ddf7c78d469 (svn r3554) Add accessors for the field type and fences of clear tiles
tron
parents: 2955
diff changeset
    45
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
    46
#endif