2005-01-29 12:19:05 +00:00
|
|
|
#ifndef TILE_H
|
|
|
|
#define TILE_H
|
|
|
|
|
2005-02-22 12:48:03 +00:00
|
|
|
#include "macros.h"
|
2005-01-29 12:19:05 +00:00
|
|
|
#include "map.h"
|
|
|
|
|
2005-01-29 15:12:40 +00:00
|
|
|
typedef enum TileType {
|
|
|
|
MP_CLEAR,
|
|
|
|
MP_RAILWAY,
|
|
|
|
MP_STREET,
|
|
|
|
MP_HOUSE,
|
|
|
|
MP_TREES,
|
|
|
|
MP_STATION,
|
|
|
|
MP_WATER,
|
|
|
|
MP_VOID, // invisible tiles at the SW and SE border
|
|
|
|
MP_INDUSTRY,
|
|
|
|
MP_TUNNELBRIDGE,
|
|
|
|
MP_UNMOVABLE
|
|
|
|
} TileType;
|
|
|
|
|
2005-05-02 18:53:06 +00:00
|
|
|
/* XXX: This should be moved out to a new file (rail.h) along with some other
|
|
|
|
* cleanups. I'll do that after 0.4) */
|
|
|
|
typedef enum {
|
|
|
|
RAILTYPE_RAIL = 0,
|
|
|
|
RAILTYPE_MONO = 1,
|
|
|
|
RAILTYPE_MAGLEV = 2,
|
|
|
|
RAILTYPE_END,
|
|
|
|
RAILTYPE_MASK = 0x3,
|
|
|
|
INVALID_RAILTYPE = 0xFF,
|
|
|
|
} RailType;
|
|
|
|
|
|
|
|
|
2005-01-29 13:33:48 +00:00
|
|
|
void SetMapExtraBits(TileIndex tile, byte flags);
|
|
|
|
uint GetMapExtraBits(TileIndex tile);
|
2005-02-07 10:41:45 +00:00
|
|
|
|
|
|
|
uint GetTileSlope(TileIndex tile, uint *h);
|
|
|
|
uint GetTileZ(TileIndex tile);
|
2005-01-29 13:33:48 +00:00
|
|
|
|
2005-02-22 12:48:03 +00:00
|
|
|
static inline bool CorrectZ(uint tileh)
|
|
|
|
{
|
|
|
|
/* tile height must be corrected if the north corner is not raised, but
|
|
|
|
* any other corner is. These are the cases 1 till 7 */
|
|
|
|
return IS_INT_INSIDE(tileh, 1, 8);
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:19:05 +00:00
|
|
|
static inline uint TileHeight(TileIndex tile)
|
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
2005-05-22 07:12:09 +00:00
|
|
|
return GB(_map_type_and_height[tile], 0, 4);
|
2005-01-29 12:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetTileHeight(TileIndex tile, uint height)
|
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
|
|
|
assert(height < 16);
|
2005-05-22 07:12:09 +00:00
|
|
|
SB(_map_type_and_height[tile], 0, 4, height);
|
2005-01-29 12:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint TilePixelHeight(TileIndex tile)
|
|
|
|
{
|
|
|
|
return TileHeight(tile) * 8;
|
|
|
|
}
|
|
|
|
|
2005-01-29 15:12:40 +00:00
|
|
|
static inline TileType GetTileType(TileIndex tile)
|
2005-01-29 12:19:05 +00:00
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
2005-05-22 07:12:09 +00:00
|
|
|
return GB(_map_type_and_height[tile], 4, 4);
|
2005-01-29 12:19:05 +00:00
|
|
|
}
|
|
|
|
|
2005-01-29 15:12:40 +00:00
|
|
|
static inline void SetTileType(TileIndex tile, TileType type)
|
2005-01-29 12:19:05 +00:00
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
2005-05-22 07:12:09 +00:00
|
|
|
SB(_map_type_and_height[tile], 4, 4, type);
|
2005-01-29 12:19:05 +00:00
|
|
|
}
|
|
|
|
|
2005-01-29 15:12:40 +00:00
|
|
|
static inline bool IsTileType(TileIndex tile, TileType type)
|
2005-01-29 12:19:05 +00:00
|
|
|
{
|
2005-01-29 15:12:40 +00:00
|
|
|
return GetTileType(tile) == type;
|
2005-01-29 12:19:05 +00:00
|
|
|
}
|
|
|
|
|
2005-02-07 10:09:28 +00:00
|
|
|
static inline Owner GetTileOwner(TileIndex tile)
|
2005-02-06 22:36:08 +00:00
|
|
|
{
|
2005-02-07 10:09:28 +00:00
|
|
|
assert(tile < MapSize());
|
2005-02-06 22:36:08 +00:00
|
|
|
return _map_owner[tile];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsTileOwner(TileIndex tile, Owner owner)
|
|
|
|
{
|
|
|
|
return GetTileOwner(tile) == owner;
|
|
|
|
}
|
|
|
|
|
2005-01-29 12:19:05 +00:00
|
|
|
#endif
|