2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
8 /** @file object_map.h Map accessors for object tiles. */
13 #include "water_map.h"
14 #include "object_type.h"
16 ObjectType
GetObjectType(TileIndex t
);
19 * Check whether the object on a tile is of a specific type.
20 * @param t Tile to test.
21 * @param type Type to test.
22 * @pre IsTileType(t, MP_OBJECT)
23 * @return True if type matches.
25 static inline bool IsObjectType(TileIndex t
, ObjectType type
)
27 return GetObjectType(t
) == type
;
31 * Check whether a tile is a object tile of a specific type.
32 * @param t Tile to test.
33 * @param type Type to test.
34 * @return True if type matches.
36 static inline bool IsObjectTypeTile(TileIndex t
, ObjectType type
)
38 return IsTileType(t
, MP_OBJECT
) && GetObjectType(t
) == type
;
42 * Get the index of which object this tile is attached to.
44 * @pre IsTileType(t, MP_OBJECT)
45 * @return The ObjectID of the object.
47 static inline ObjectID
GetObjectIndex(TileIndex t
)
49 assert(IsTileType(t
, MP_OBJECT
));
50 return _m
[t
].m2
| _m
[t
].m5
<< 16;
54 * Get the random bits of this tile.
55 * @param t The tile to get the bits for.
56 * @pre IsTileType(t, MP_OBJECT)
57 * @return The random bits.
59 static inline byte
GetObjectRandomBits(TileIndex t
)
61 assert(IsTileType(t
, MP_OBJECT
));
67 * Make an Object tile.
68 * @param t The tile to make and object tile.
69 * @param o The new owner of the tile.
70 * @param index Index to the object.
71 * @param wc Water class for this object.
72 * @param random Random data to store on the tile
74 static inline void MakeObject(TileIndex t
, Owner o
, ObjectID index
, WaterClass wc
, byte random
)
76 SetTileType(t
, MP_OBJECT
);
82 _m
[t
].m5
= index
>> 16;
83 SB(_me
[t
].m6
, 2, 4, 0);
87 #endif /* OBJECT_MAP_H */