# object_map.h

Go to the documentation of this file.

    00001 /* $Id$ */
    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
    00024 static inline ObjectType GetObjectType(TileIndex t)
    00025 {
    00026   assert(IsTileType(t, MP_OBJECT));
    00027   return (ObjectType)_m[t].m5;
    00028 }
    00029
    00036 static inline ObjectID GetObjectIndex(TileIndex t)
    00037 {
    00038   assert(IsTileType(t, MP_OBJECT));
    00039   return _m[t].m2;
    00040 }
    00041
    00047 static inline bool IsTransmitterTile(TileIndex t)
    00048 {
    00049   return IsTileType(t, MP_OBJECT) && GetObjectType(t) == OBJECT_TRANSMITTER;
    00050 }
    00051
    00058 static inline bool IsOwnedLand(TileIndex t)
    00059 {
    00060   assert(IsTileType(t, MP_OBJECT));
    00061   return GetObjectType(t) == OBJECT_OWNED_LAND;
    00062 }
    00063
    00069 static inline bool IsOwnedLandTile(TileIndex t)
    00070 {
    00071   return IsTileType(t, MP_OBJECT) && IsOwnedLand(t);
    00072 }
    00073
    00080 static inline bool IsCompanyHQ(TileIndex t)
    00081 {
    00082   assert(IsTileType(t, MP_OBJECT));
    00083   return _m[t].m5 == OBJECT_HQ;
    00084 }
    00085
    00092 static inline bool IsStatue(TileIndex t)
    00093 {
    00094   assert(IsTileType(t, MP_OBJECT));
    00095   return GetObjectType(t) == OBJECT_STATUE;
    00096 }
    00097
    00103 static inline bool IsStatueTile(TileIndex t)
    00104 {
    00105   return IsTileType(t, MP_OBJECT) && IsStatue(t);
    00106 }
    00107
    00114 static inline byte GetObjectRandomBits(TileIndex t)
    00115 {
    00116   assert(IsTileType(t, MP_OBJECT));
    00117   return _m[t].m3;
    00118 }
    00119
    00120
    00131 static inline void MakeObject(TileIndex t, ObjectType u, Owner o, ObjectID index, WaterClass wc, byte random)
    00132 {
    00133   SetTileType(t, MP_OBJECT);
    00134   SetTileOwner(t, o);
    00135   SetWaterClass(t, wc);
    00136   _m[t].m2 = index;
    00137   _m[t].m3 = random;
    00138   _m[t].m4 = 0;
    00139   _m[t].m5 = u;
    00140   SB(_m[t].m6, 2, 4, 0);
    00141   _me[t].m7 = 0;
    00142 }
    00143
    00144 #endif /* OBJECT_MAP_H */