tron@2186: /* $Id$ */ tron@2186: tron@1209: #ifndef TILE_H tron@1209: #define TILE_H tron@926: tron@1394: #include "macros.h" tron@1209: #include "map.h" tron@3636: #include "slope.h" tron@1035: matthijs@1944: typedef enum TileTypes { 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, celestar@5590: //MP_TUNNELBRIDGE, celestar@5590: MP_TUNNEL, ludde@2125: MP_UNMOVABLE, celestar@5590: MP_RAILWAY_BRIDGE, celestar@5590: MP_STREET_BRIDGE tron@1214: } TileType; tron@1214: belugas@3379: typedef enum TropicZones { rubidium@4344: TROPICZONE_INVALID = 0, rubidium@4344: TROPICZONE_DESERT = 1, belugas@3379: TROPICZONE_RAINFOREST = 2, belugas@3379: } TropicZone; tron@1211: tron@3636: Slope GetTileSlope(TileIndex tile, uint *h); tron@1335: uint GetTileZ(TileIndex tile); tron@3773: uint GetTileMaxZ(TileIndex tile); tron@1335: tron@1044: static inline uint TileHeight(TileIndex tile) tron@1044: { tron@1044: assert(tile < MapSize()); tron@2049: return GB(_m[tile].type_height, 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@2049: SB(_m[tile].type_height, 0, 4, height); tron@1059: } tron@1059: tron@1041: static inline uint TilePixelHeight(TileIndex tile) tron@1035: { tron@4077: return TileHeight(tile) * TILE_HEIGHT; tron@1035: } tron@1035: tron@1214: static inline TileType GetTileType(TileIndex tile) tron@1035: { tron@1035: assert(tile < MapSize()); KUDr@3900: return (TileType)GB(_m[tile].type_height, 4, 4); tron@1035: } tron@1035: tron@1214: static inline void SetTileType(TileIndex tile, TileType type) tron@1059: { tron@1059: assert(tile < MapSize()); tron@4010: /* VOID tiles (and no others) are exactly allowed at the lower left and right tron@4077: * edges of the map */ tron@4010: assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID)); tron@2049: SB(_m[tile].type_height, 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: ludde@2125: tron@1333: static inline Owner GetTileOwner(TileIndex tile) matthijs@1330: { tron@1333: assert(tile < MapSize()); tron@1898: assert(!IsTileType(tile, MP_HOUSE)); tron@1898: assert(!IsTileType(tile, MP_VOID)); tron@1898: assert(!IsTileType(tile, MP_INDUSTRY)); tron@1898: KUDr@3900: return (Owner)_m[tile].m1; matthijs@1330: } matthijs@1330: tron@1902: static inline void SetTileOwner(TileIndex tile, Owner owner) tron@1902: { tron@1902: assert(tile < MapSize()); tron@1902: assert(!IsTileType(tile, MP_HOUSE)); tron@1902: assert(!IsTileType(tile, MP_VOID)); tron@1902: assert(!IsTileType(tile, MP_INDUSTRY)); tron@1902: tron@2360: _m[tile].m1 = owner; tron@1902: } tron@1902: matthijs@1330: static inline bool IsTileOwner(TileIndex tile, Owner owner) matthijs@1330: { matthijs@1330: return GetTileOwner(tile) == owner; matthijs@1330: } matthijs@1330: belugas@3379: /** belugas@3379: * Set the tropic zone belugas@3379: * @param tile the tile to set the zone of belugas@3379: * @param type the new type belugas@3379: * @pre assert(tile < MapSize()); belugas@3379: */ belugas@3379: static inline void SetTropicZone(TileIndex tile, TropicZone type) belugas@3379: { belugas@3379: assert(tile < MapSize()); belugas@3379: SB(_m[tile].extra, 0, 2, type); belugas@3379: } belugas@3379: belugas@3379: /** belugas@3379: * Get the tropic zone belugas@3379: * @param tile the tile to get the zone of belugas@3379: * @pre assert(tile < MapSize()); belugas@3379: * @return the zone type belugas@3379: */ belugas@3379: static inline TropicZone GetTropicZone(TileIndex tile) belugas@3379: { belugas@3379: assert(tile < MapSize()); belugas@3379: return (TropicZone)GB(_m[tile].extra, 0, 2); belugas@3379: } Darkvater@2436: #endif /* TILE_H */