summaryrefslogtreecommitdiff
path: root/unmovable_map.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2006-03-23 20:47:56 +0000
committertron <tron@openttd.org>2006-03-23 20:47:56 +0000
commit541703a2f6687fcb7d9f4d1453f84d80b67cd58c (patch)
tree5fe90832d23bf4493a9bb128090d8109bf163cc1 /unmovable_map.h
parent6d4e7d565da547888f0cf5a0fdff038924b3a9a4 (diff)
downloadopenttd-541703a2f6687fcb7d9f4d1453f84d80b67cd58c.tar.xz
(svn r4073) Add functions to make and test for (most) unmovable tiles
Diffstat (limited to 'unmovable_map.h')
-rw-r--r--unmovable_map.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/unmovable_map.h b/unmovable_map.h
new file mode 100644
index 000000000..32375c2cd
--- /dev/null
+++ b/unmovable_map.h
@@ -0,0 +1,65 @@
+/* $Id$ */
+
+typedef enum UnmovableType {
+ UNMOVABLE_TRANSMITTER = 0,
+ UNMOVABLE_LIGHTHOUSE = 1,
+ UNMOVABLE_STATUE = 2,
+ UNMOVABLE_OWNED_LAND = 3
+} UnmovableType;
+
+
+static inline UnmovableType GetUnmovableType(TileIndex t)
+{
+ return _m[t].m5;
+}
+
+
+static inline bool IsTransmitterTile(TileIndex t)
+{
+ return
+ IsTileType(t, MP_UNMOVABLE) &&
+ GetUnmovableType(t) == UNMOVABLE_TRANSMITTER;
+}
+
+
+static inline bool IsOwnedLand(TileIndex t)
+{
+ return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND;
+}
+
+static inline bool IsOwnedLandTile(TileIndex t)
+{
+ return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
+}
+
+
+static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
+{
+ SetTileType(t, MP_UNMOVABLE);
+ SetTileOwner(t, o);
+ _m[t].m2 = 0;
+ _m[t].m3 = 0;
+ _m[t].m4 = 0;
+ _m[t].m5 = u;
+}
+
+
+static inline void MakeTransmitter(TileIndex t)
+{
+ MakeUnmovable(t, UNMOVABLE_TRANSMITTER, OWNER_NONE);
+}
+
+static inline void MakeLighthouse(TileIndex t)
+{
+ MakeUnmovable(t, UNMOVABLE_LIGHTHOUSE, OWNER_NONE);
+}
+
+static inline void MakeStatue(TileIndex t, Owner o)
+{
+ MakeUnmovable(t, UNMOVABLE_STATUE, o);
+}
+
+static inline void MakeOwnedLand(TileIndex t, Owner o)
+{
+ MakeUnmovable(t, UNMOVABLE_OWNED_LAND, o);
+}