tron@1209: #ifndef TILE_H tron@1209: #define TILE_H tron@926: tron@1394: #include "macros.h" tron@1209: #include "map.h" tron@1035: tron@1214: typedef enum TileType { tron@1214: MP_CLEAR, tron@1214: MP_RAILWAY, tron@1214: MP_STREET, tron@1214: MP_HOUSE, tron@1214: MP_TREES, tron@1214: MP_STATION, tron@1214: MP_WATER, tron@1214: MP_VOID, // invisible tiles at the SW and SE border tron@1214: MP_INDUSTRY, tron@1214: MP_TUNNELBRIDGE, tron@1214: MP_UNMOVABLE tron@1214: } TileType; tron@1214: matthijs@1749: /* XXX: This should be moved out to a new file (rail.h) along with some other matthijs@1749: * cleanups. I'll do that after 0.4) */ matthijs@1749: typedef enum { matthijs@1749: RAILTYPE_RAIL = 0, matthijs@1749: RAILTYPE_MONO = 1, matthijs@1749: RAILTYPE_MAGLEV = 2, matthijs@1749: RAILTYPE_END, matthijs@1749: RAILTYPE_MASK = 0x3, matthijs@1749: INVALID_RAILTYPE = 0xFF, matthijs@1749: } RailType; matthijs@1749: matthijs@1749: tron@1211: void SetMapExtraBits(TileIndex tile, byte flags); tron@1211: uint GetMapExtraBits(TileIndex tile); tron@1211: tron@1335: uint GetTileSlope(TileIndex tile, uint *h); tron@1335: uint GetTileZ(TileIndex tile); tron@1335: tron@1394: static inline bool CorrectZ(uint tileh) tron@1394: { tron@1394: /* tile height must be corrected if the north corner is not raised, but tron@1394: * any other corner is. These are the cases 1 till 7 */ tron@1394: return IS_INT_INSIDE(tileh, 1, 8); tron@1394: } tron@1394: tron@1044: static inline uint TileHeight(TileIndex tile) tron@1044: { tron@1044: assert(tile < MapSize()); tron@1852: return GB(_map_type_and_height[tile], 0, 4); tron@1044: } tron@1044: tron@1059: static inline void SetTileHeight(TileIndex tile, uint height) tron@1059: { tron@1059: assert(tile < MapSize()); tron@1059: assert(height < 16); tron@1852: SB(_map_type_and_height[tile], 0, 4, height); tron@1059: } tron@1059: tron@1041: static inline uint TilePixelHeight(TileIndex tile) tron@1035: { tron@1044: return TileHeight(tile) * 8; tron@1035: } tron@1035: tron@1214: static inline TileType GetTileType(TileIndex tile) tron@1035: { tron@1035: assert(tile < MapSize()); tron@1852: return GB(_map_type_and_height[tile], 4, 4); tron@1035: } tron@1035: tron@1214: static inline void SetTileType(TileIndex tile, TileType type) tron@1059: { tron@1059: assert(tile < MapSize()); tron@1852: SB(_map_type_and_height[tile], 4, 4, type); tron@1059: } tron@1059: tron@1214: static inline bool IsTileType(TileIndex tile, TileType type) tron@1035: { tron@1214: return GetTileType(tile) == type; tron@1035: } tron@1035: tron@1333: static inline Owner GetTileOwner(TileIndex tile) matthijs@1330: { tron@1333: assert(tile < MapSize()); matthijs@1330: return _map_owner[tile]; matthijs@1330: } matthijs@1330: matthijs@1330: static inline bool IsTileOwner(TileIndex tile, Owner owner) matthijs@1330: { matthijs@1330: return GetTileOwner(tile) == owner; matthijs@1330: } matthijs@1330: tron@679: #endif