(svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free

This commit is contained in:
celestar
2006-04-03 12:20:55 +00:00
parent 7eedaf9a0e
commit e2db84101e
2 changed files with 74 additions and 65 deletions

View File

@@ -1,5 +1,10 @@
/* $Id$ */
enum {
HQ_NUM_TILE = 4,
HQ_NUM_SIZE = 5
};
typedef enum UnmovableType {
UNMOVABLE_TRANSMITTER = 0,
UNMOVABLE_LIGHTHOUSE = 1,
@@ -9,9 +14,12 @@ typedef enum UnmovableType {
UNMOVABLE_HQ_WEST = 0x81,
UNMOVABLE_HQ_EAST = 0x82,
UNMOVABLE_HQ_SOUTH = 0x83,
UNMOVABLE_HQ_END = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE
} UnmovableType;
static inline UnmovableType GetUnmovableType(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE));
@@ -38,6 +46,23 @@ static inline bool IsOwnedLandTile(TileIndex t)
return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
}
static inline bool IsCompanyHQ(TileIndex t)
{
return IS_INT_INSIDE(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
}
static inline byte GetCompanyHQSize(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
return GB(_m[t].m5, 2, 3);
}
static inline byte GetCompanyHQSection(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
return GB(_m[t].m5, 0, 5);
}
static inline void EnlargeCompanyHQ(TileIndex t, byte size)
{