4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file object_map.h Map accessors for object tiles. */
15 #include "water_map.h"
16 #include "object_type.h"
19 * Gets the ObjectType of the given object tile
20 * @param t the tile to get the type from.
21 * @pre IsTileType(t, MP_OBJECT)
24 static inline ObjectType
GetObjectType(TileIndex t
)
26 assert(IsTileType(t
, MP_OBJECT
));
27 return (ObjectType
)_m
[t
].m5
;
31 * Get the index of which object this tile is attached to.
33 * @pre IsTileType(t, MP_OBJECT)
34 * @return The ObjectID of the object.
36 static inline ObjectID
GetObjectIndex(TileIndex t
)
38 assert(IsTileType(t
, MP_OBJECT
));
43 * Does the given tile have a transmitter?
44 * @param t the tile to inspect.
45 * @return true if and only if the tile has a transmitter.
47 static inline bool IsTransmitterTile(TileIndex t
)
49 return IsTileType(t
, MP_OBJECT
) && GetObjectType(t
) == OBJECT_TRANSMITTER
;
53 * Is this object tile an 'owned land' tile?
54 * @param t the tile to inspect.
55 * @pre IsTileType(t, MP_OBJECT)
56 * @return true if and only if the tile is an 'owned land' tile.
58 static inline bool IsOwnedLand(TileIndex t
)
60 assert(IsTileType(t
, MP_OBJECT
));
61 return GetObjectType(t
) == OBJECT_OWNED_LAND
;
65 * Is the given tile (pre-)owned by someone (the little flags)?
66 * @param t the tile to inspect.
67 * @return true if and only if the tile is an 'owned land' tile.
69 static inline bool IsOwnedLandTile(TileIndex t
)
71 return IsTileType(t
, MP_OBJECT
) && IsOwnedLand(t
);
75 * Is this object tile a HQ tile?
76 * @param t the tile to inspect.
77 * @pre IsTileType(t, MP_OBJECT)
78 * @return true if and only if the tile is a HQ tile.
80 static inline bool IsCompanyHQ(TileIndex t
)
82 assert(IsTileType(t
, MP_OBJECT
));
83 return _m
[t
].m5
== OBJECT_HQ
;
87 * Is this object tile a statue?
88 * @param t the tile to inspect.
89 * @pre IsTileType(t, MP_OBJECT)
90 * @return true if and only if the tile is a statue.
92 static inline bool IsStatue(TileIndex t
)
94 assert(IsTileType(t
, MP_OBJECT
));
95 return GetObjectType(t
) == OBJECT_STATUE
;
99 * Is the given tile a statue?
100 * @param t the tile to inspect.
101 * @return true if and only if the tile is a statue.
103 static inline bool IsStatueTile(TileIndex t
)
105 return IsTileType(t
, MP_OBJECT
) && IsStatue(t
);
109 * Get the random bits of this tile.
110 * @param t The tile to get the bits for.
111 * @pre IsTileType(t, MP_OBJECT)
112 * @return The random bits.
114 static inline byte
GetObjectRandomBits(TileIndex t
)
116 assert(IsTileType(t
, MP_OBJECT
));
122 * Make an Object tile.
123 * @note do not use this function directly. Use one of the other Make* functions.
124 * @param t The tile to make and object tile.
125 * @param u The object type of the tile.
126 * @param o The new owner of the tile.
127 * @param index Index to the object.
128 * @param wc Water class for this object.
129 * @param random Random data to store on the tile
131 static inline void MakeObject(TileIndex t
, ObjectType u
, Owner o
, ObjectID index
, WaterClass wc
, byte random
)
133 SetTileType(t
, MP_OBJECT
);
135 SetWaterClass(t
, wc
);
140 SB(_m
[t
].m6
, 2, 4, 0);
144 #endif /* OBJECT_MAP_H */