object_map.h

Go to the documentation of this file.
00001 /* $Id: object_map.h 25844 2013-10-12 16:35:50Z frosch $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef OBJECT_MAP_H
00013 #define OBJECT_MAP_H
00014 
00015 #include "water_map.h"
00016 #include "object_type.h"
00017 
00018 ObjectType GetObjectType(TileIndex t);
00019 
00027 static inline bool IsObjectType(TileIndex t, ObjectType type)
00028 {
00029   return GetObjectType(t) == type;
00030 }
00031 
00038 static inline bool IsObjectTypeTile(TileIndex t, ObjectType type)
00039 {
00040   return IsTileType(t, MP_OBJECT) && GetObjectType(t) == type;
00041 }
00042 
00049 static inline ObjectID GetObjectIndex(TileIndex t)
00050 {
00051   assert(IsTileType(t, MP_OBJECT));
00052   return _m[t].m2 | _m[t].m5 << 16;
00053 }
00054 
00061 static inline byte GetObjectRandomBits(TileIndex t)
00062 {
00063   assert(IsTileType(t, MP_OBJECT));
00064   return _m[t].m3;
00065 }
00066 
00067 
00076 static inline void MakeObject(TileIndex t, Owner o, ObjectID index, WaterClass wc, byte random)
00077 {
00078   SetTileType(t, MP_OBJECT);
00079   SetTileOwner(t, o);
00080   SetWaterClass(t, wc);
00081   _m[t].m2 = index;
00082   _m[t].m3 = random;
00083   _m[t].m4 = 0;
00084   _m[t].m5 = index >> 16;
00085   SB(_m[t].m6, 2, 4, 0);
00086   _me[t].m7 = 0;
00087 }
00088 
00089 #endif /* OBJECT_MAP_H */