2006-02-01 15:31:21 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2006-03-05 11:18:34 +00:00
|
|
|
#ifndef CLEAR_MAP_H
|
|
|
|
#define CLEAR_MAP_H
|
2006-02-01 15:31:21 +00:00
|
|
|
|
|
|
|
#include "macros.h"
|
2006-02-24 19:56:24 +00:00
|
|
|
#include "tile.h"
|
2006-02-01 15:31:21 +00:00
|
|
|
|
|
|
|
/* ground type, m5 bits 2...4
|
|
|
|
* valid densities (bits 0...1) in comments after the enum
|
|
|
|
*/
|
|
|
|
typedef enum ClearGround {
|
2006-04-04 21:35:13 +00:00
|
|
|
CLEAR_GRASS = 0, // 0-3
|
|
|
|
CLEAR_ROUGH = 1, // 3
|
|
|
|
CLEAR_ROCKS = 2, // 3
|
|
|
|
CLEAR_FIELDS = 3, // 3
|
|
|
|
CLEAR_SNOW = 4, // 0-3
|
|
|
|
CLEAR_DESERT = 5 // 1,3
|
2006-02-01 15:31:21 +00:00
|
|
|
} ClearGround;
|
|
|
|
|
|
|
|
|
2006-03-30 09:29:01 +00:00
|
|
|
static inline ClearGround GetClearGround(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR));
|
|
|
|
return GB(_m[t].m5, 2, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsClearGround(TileIndex t, ClearGround ct)
|
|
|
|
{
|
|
|
|
return GetClearGround(t) == ct;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline uint GetClearDensity(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR));
|
|
|
|
return GB(_m[t].m5, 0, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void AddClearDensity(TileIndex t, int d)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
|
|
|
|
_m[t].m5 += d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline uint GetClearCounter(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR));
|
|
|
|
return GB(_m[t].m5, 5, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void AddClearCounter(TileIndex t, int c)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
|
|
|
|
_m[t].m5 += c << 5;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetClearCounter(TileIndex t, uint c)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
|
|
|
|
SB(_m[t].m5, 5, 3, c);
|
|
|
|
}
|
2006-02-01 15:31:21 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Sets type and density in one go, also sets the counter to 0 */
|
|
|
|
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
|
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
|
2006-02-01 15:31:21 +00:00
|
|
|
_m[t].m5 = 0 << 5 | type << 2 | density;
|
|
|
|
}
|
|
|
|
|
2006-03-30 09:29:01 +00:00
|
|
|
|
|
|
|
static inline uint GetFieldType(TileIndex t)
|
|
|
|
{
|
2006-04-04 21:35:13 +00:00
|
|
|
assert(GetClearGround(t) == CLEAR_FIELDS);
|
2006-03-30 09:29:01 +00:00
|
|
|
return GB(_m[t].m3, 0, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetFieldType(TileIndex t, uint f)
|
|
|
|
{
|
2006-04-04 21:35:13 +00:00
|
|
|
assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete
|
2006-03-30 09:29:01 +00:00
|
|
|
SB(_m[t].m3, 0, 4, f);
|
|
|
|
}
|
|
|
|
|
2006-08-20 18:44:26 +00:00
|
|
|
static inline uint16 GetIndustryIndexOfField(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(GetClearGround(t) == CLEAR_FIELDS);
|
|
|
|
return _m[t].m2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetIndustryIndexOfField(TileIndex t, uint16 i)
|
|
|
|
{
|
|
|
|
assert(GetClearGround(t) == CLEAR_FIELDS);
|
|
|
|
_m[t].m2 = i;
|
|
|
|
}
|
2006-02-05 11:54:25 +00:00
|
|
|
|
|
|
|
/* Is used by tree tiles, too */
|
2006-03-30 09:29:01 +00:00
|
|
|
static inline uint GetFenceSE(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
|
|
|
|
return GB(_m[t].m4, 2, 3);
|
|
|
|
}
|
2006-02-05 11:54:25 +00:00
|
|
|
|
2006-03-30 09:29:01 +00:00
|
|
|
static inline void SetFenceSE(TileIndex t, uint h)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete
|
|
|
|
SB(_m[t].m4, 2, 3, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint GetFenceSW(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
|
|
|
|
return GB(_m[t].m4, 5, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetFenceSW(TileIndex t, uint h)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete
|
|
|
|
SB(_m[t].m4, 5, 3, h);
|
|
|
|
}
|
2006-02-05 11:54:25 +00:00
|
|
|
|
2006-02-24 19:56:24 +00:00
|
|
|
|
|
|
|
static inline void MakeClear(TileIndex t, ClearGround g, uint density)
|
|
|
|
{
|
|
|
|
SetTileType(t, MP_CLEAR);
|
|
|
|
SetTileOwner(t, OWNER_NONE);
|
|
|
|
_m[t].m2 = 0;
|
|
|
|
_m[t].m3 = 0;
|
|
|
|
_m[t].m4 = 0 << 5 | 0 << 2;
|
2006-03-22 08:48:50 +00:00
|
|
|
SetClearGroundDensity(t, g, density);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-20 18:44:26 +00:00
|
|
|
static inline void MakeField(TileIndex t, uint field_type, uint16 industry)
|
2006-03-22 08:48:50 +00:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_CLEAR);
|
|
|
|
SetTileOwner(t, OWNER_NONE);
|
2006-08-20 18:44:26 +00:00
|
|
|
_m[t].m2 = industry;
|
2006-03-22 08:48:50 +00:00
|
|
|
_m[t].m3 = field_type;
|
|
|
|
_m[t].m4 = 0 << 5 | 0 << 2;
|
2006-04-04 21:35:13 +00:00
|
|
|
SetClearGroundDensity(t, CLEAR_FIELDS, 3);
|
2006-02-24 19:56:24 +00:00
|
|
|
}
|
|
|
|
|
2006-02-01 15:31:21 +00:00
|
|
|
#endif
|