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(Tile 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 inline bool IsObjectType(Tile 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 inline bool IsObjectTypeTile(Tile 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 inline ObjectID
GetObjectIndex(Tile t
)
49 assert(IsTileType(t
, MP_OBJECT
));
50 return t
.m2() | 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 inline byte
GetObjectRandomBits(Tile 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 inline void MakeObject(Tile t
, Owner o
, ObjectID index
, WaterClass wc
, byte random
)
76 SetTileType(t
, MP_OBJECT
);
87 #endif /* OBJECT_MAP_H */