tron@2955: /* $Id$ */ tron@2955: tron@3145: #ifndef CLEAR_MAP_H tron@3145: #define CLEAR_MAP_H tron@2955: tron@2955: #include "macros.h" tron@3076: #include "tile.h" tron@2955: tron@2955: /* ground type, m5 bits 2...4 tron@2955: * valid densities (bits 0...1) in comments after the enum tron@2955: */ tron@2955: typedef enum ClearGround { tron@2955: CL_GRASS = 0, // 0-3 tron@2955: CL_ROUGH = 1, // 3 tron@2955: CL_ROCKS = 2, // 3 tron@2955: CL_FIELDS = 3, // 3 tron@2955: CL_SNOW = 4, // 0-3 tron@2955: CL_DESERT = 5 // 1,3 tron@2955: } ClearGround; tron@2955: tron@2955: static inline ClearGround GetClearGround(TileIndex t) { return GB(_m[t].m5, 2, 3); } tron@2955: static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; } tron@2955: tron@2955: static inline void AddClearDensity(TileIndex t, int d) { _m[t].m5 += d; } tron@2955: static inline uint GetClearDensity(TileIndex t) { return GB(_m[t].m5, 0, 2); } tron@2955: tron@2955: static inline void AddClearCounter(TileIndex t, int c) { _m[t].m5 += c << 5; } tron@2955: static inline uint GetClearCounter(TileIndex t) { return GB(_m[t].m5, 5, 3); } tron@2955: static inline void SetClearCounter(TileIndex t, uint c) { SB(_m[t].m5, 5, 3, c); } tron@2955: tron@2955: /* Sets type and density in one go, also sets the counter to 0 */ tron@2955: static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density) tron@2955: { tron@2955: _m[t].m5 = 0 << 5 | type << 2 | density; tron@2955: } tron@2955: tron@2979: static inline uint GetFieldType(TileIndex t) { return GB(_m[t].m3, 0, 4); } tron@2979: static inline void SetFieldType(TileIndex t, uint f) { SB(_m[t].m3, 0, 4, f); } tron@2979: tron@2979: /* Is used by tree tiles, too */ tron@2979: static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); } tron@2979: static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); } tron@2979: tron@2979: static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); } tron@2979: static inline void SetFenceSW(TileIndex t, uint h) { SB(_m[t].m4, 5, 3, h); } tron@2979: tron@3076: tron@3076: static inline void MakeClear(TileIndex t, ClearGround g, uint density) tron@3076: { tron@3076: SetTileType(t, MP_CLEAR); tron@3076: SetTileOwner(t, OWNER_NONE); tron@3076: _m[t].m2 = 0; tron@3076: _m[t].m3 = 0; tron@3076: _m[t].m4 = 0 << 5 | 0 << 2; tron@3076: _m[t].m5 = 0 << 5 | g << 2 | density; tron@3076: } tron@3076: tron@2955: #endif