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"
18 ObjectType
GetObjectType(TileIndex t
);
21 * Check whether the object on a tile is of a specific type.
22 * @param t Tile to test.
23 * @param type Type to test.
24 * @pre IsTileType(t, MP_OBJECT)
25 * @return True if type matches.
27 static inline bool IsObjectType(TileIndex t
, ObjectType type
)
29 return GetObjectType(t
) == type
;
33 * Check whether a tile is a object tile of a specific type.
34 * @param t Tile to test.
35 * @param type Type to test.
36 * @return True if type matches.
38 static inline bool IsObjectTypeTile(TileIndex t
, ObjectType type
)
40 return IsTileType(t
, MP_OBJECT
) && GetObjectType(t
) == type
;
44 * Get the index of which object this tile is attached to.
46 * @pre IsTileType(t, MP_OBJECT)
47 * @return The ObjectID of the object.
49 static inline ObjectID
GetObjectIndex(TileIndex t
)
51 assert(IsTileType(t
, MP_OBJECT
));
52 return _m
[t
].m2
| _m
[t
].m5
<< 16;
56 * Get the random bits of this tile.
57 * @param t The tile to get the bits for.
58 * @pre IsTileType(t, MP_OBJECT)
59 * @return The random bits.
61 static inline byte
GetObjectRandomBits(TileIndex t
)
63 assert(IsTileType(t
, MP_OBJECT
));
69 * Make an Object tile.
70 * @param t The tile to make and object tile.
71 * @param o The new owner of the tile.
72 * @param index Index to the object.
73 * @param wc Water class for this object.
74 * @param random Random data to store on the tile
76 static inline void MakeObject(TileIndex t
, Owner o
, ObjectID index
, WaterClass wc
, byte random
)
78 SetTileType(t
, MP_OBJECT
);
84 _m
[t
].m5
= index
>> 16;
85 SB(_me
[t
].m6
, 2, 4, 0);
89 #endif /* OBJECT_MAP_H */