summaryrefslogtreecommitdiff
path: root/unmovable_map.h
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-03 12:20:55 +0000
committercelestar <celestar@openttd.org>2006-04-03 12:20:55 +0000
commite2db84101e2857ce0ff7ed927cc9a80e603fd52d (patch)
tree75b82a8249e1db78e1e7a97a5da2ea48f14529f5 /unmovable_map.h
parent7eedaf9a0ec70a53e6f5e74979c3304113587981 (diff)
downloadopenttd-e2db84101e2857ce0ff7ed927cc9a80e603fd52d.tar.xz
(svn r4255) -Codechange: Add and make use of more accessor functions concerning unmovables. unmovable_cmd is now map access free
Diffstat (limited to 'unmovable_map.h')
-rw-r--r--unmovable_map.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/unmovable_map.h b/unmovable_map.h
index fed814ced..d8ee49a0b 100644
--- a/unmovable_map.h
+++ b/unmovable_map.h
@@ -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)
{