OpenTTD: src/object_map.h Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

object_map.h
Go to the documentation of this file.
1 /* $Id: object_map.h 26878 2014-09-21 11:23:33Z rubidium $ */
2
3 /*
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/>.
8 */
9
12 #ifndef OBJECT_MAP_H
13 #define OBJECT_MAP_H
14
15 #include "water_map.h"
16 #include "object_type.h"
17
18 ObjectType GetObjectType(TileIndex t);
19
27 static inline bool IsObjectType(TileIndex t, ObjectType type)
28 {
29 return GetObjectType(t) == type;
30 }
31
38 static inline bool IsObjectTypeTile(TileIndex t, ObjectType type)
39 {
40 return IsTileType(t, MP_OBJECT) && GetObjectType(t) == type;
41 }
42
49 static inline ObjectID GetObjectIndex(TileIndex t)
50 {
51 assert(IsTileType(t, MP_OBJECT));
52 return _m[t].m2 | _m[t].m5 << 16;
53 }
54
61 static inline byte GetObjectRandomBits(TileIndex t)
62 {
63 assert(IsTileType(t, MP_OBJECT));
64 return _m[t].m3;
65 }
66
67
76 static inline void MakeObject(TileIndex t, Owner o, ObjectID index, WaterClass wc, byte random)
77 {
78 SetTileType(t, MP_OBJECT);
79 SetTileOwner(t, o);
80 SetWaterClass(t, wc);
81 _m[t].m2 = index;
82 _m[t].m3 = random;
83 _m[t].m4 = 0;
84 _m[t].m5 = index >> 16;
85 SB(_me[t].m6, 2, 4, 0);
86 _me[t].m7 = 0;
87 }
88
89 #endif /* OBJECT_MAP_H */