2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
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"
|
2006-04-23 13:48:16 +00:00
|
|
|
#include "slope.h"
|
2005-01-29 12:19:05 +00:00
|
|
|
|
2005-06-17 00:22:46 +00:00
|
|
|
typedef enum TileTypes {
|
2005-01-29 15:12:40 +00:00
|
|
|
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,
|
2005-07-19 11:42:40 +00:00
|
|
|
MP_UNMOVABLE,
|
2005-01-29 15:12:40 +00:00
|
|
|
} TileType;
|
|
|
|
|
2006-03-30 19:16:44 +00:00
|
|
|
typedef enum TropicZones {
|
2006-08-22 14:38:37 +00:00
|
|
|
TROPICZONE_INVALID = 0,
|
|
|
|
TROPICZONE_DESERT = 1,
|
2006-03-30 19:16:44 +00:00
|
|
|
TROPICZONE_RAINFOREST = 2,
|
|
|
|
} TropicZone;
|
2005-02-07 10:41:45 +00:00
|
|
|
|
2006-04-23 13:48:16 +00:00
|
|
|
Slope GetTileSlope(TileIndex tile, uint *h);
|
2005-02-07 10:41:45 +00:00
|
|
|
uint GetTileZ(TileIndex tile);
|
2006-05-07 07:55:05 +00:00
|
|
|
uint GetTileMaxZ(TileIndex tile);
|
2005-01-29 13:33:48 +00:00
|
|
|
|
2005-01-29 12:19:05 +00:00
|
|
|
static inline uint TileHeight(TileIndex tile)
|
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
2005-07-13 18:04:01 +00:00
|
|
|
return GB(_m[tile].type_height, 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-07-13 18:04:01 +00:00
|
|
|
SB(_m[tile].type_height, 0, 4, height);
|
2005-01-29 12:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint TilePixelHeight(TileIndex tile)
|
|
|
|
{
|
2006-06-27 21:25:53 +00:00
|
|
|
return TileHeight(tile) * TILE_HEIGHT;
|
2005-01-29 12:19:05 +00:00
|
|
|
}
|
|
|
|
|
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());
|
2006-05-27 16:12:16 +00:00
|
|
|
return (TileType)GB(_m[tile].type_height, 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());
|
2006-06-10 21:06:29 +00:00
|
|
|
/* VOID tiles (and no others) are exactly allowed at the lower left and right
|
2006-06-27 21:25:53 +00:00
|
|
|
* edges of the map */
|
2006-06-10 21:06:29 +00:00
|
|
|
assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID));
|
2005-07-13 18:04:01 +00:00
|
|
|
SB(_m[tile].type_height, 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-07-19 11:42:40 +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-06-03 22:43:59 +00:00
|
|
|
assert(!IsTileType(tile, MP_HOUSE));
|
|
|
|
assert(!IsTileType(tile, MP_VOID));
|
|
|
|
assert(!IsTileType(tile, MP_INDUSTRY));
|
|
|
|
|
2006-05-27 16:12:16 +00:00
|
|
|
return (Owner)_m[tile].m1;
|
2005-02-06 22:36:08 +00:00
|
|
|
}
|
|
|
|
|
2005-06-04 12:13:24 +00:00
|
|
|
static inline void SetTileOwner(TileIndex tile, Owner owner)
|
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
|
|
|
assert(!IsTileType(tile, MP_HOUSE));
|
|
|
|
assert(!IsTileType(tile, MP_VOID));
|
|
|
|
assert(!IsTileType(tile, MP_INDUSTRY));
|
|
|
|
|
2005-08-23 18:47:04 +00:00
|
|
|
_m[tile].m1 = owner;
|
2005-06-04 12:13:24 +00:00
|
|
|
}
|
|
|
|
|
2005-02-06 22:36:08 +00:00
|
|
|
static inline bool IsTileOwner(TileIndex tile, Owner owner)
|
|
|
|
{
|
|
|
|
return GetTileOwner(tile) == owner;
|
|
|
|
}
|
|
|
|
|
2006-03-30 19:16:44 +00:00
|
|
|
/**
|
|
|
|
* Set the tropic zone
|
|
|
|
* @param tile the tile to set the zone of
|
|
|
|
* @param type the new type
|
|
|
|
* @pre assert(tile < MapSize());
|
|
|
|
*/
|
|
|
|
static inline void SetTropicZone(TileIndex tile, TropicZone type)
|
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
|
|
|
SB(_m[tile].extra, 0, 2, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the tropic zone
|
|
|
|
* @param tile the tile to get the zone of
|
|
|
|
* @pre assert(tile < MapSize());
|
|
|
|
* @return the zone type
|
|
|
|
*/
|
|
|
|
static inline TropicZone GetTropicZone(TileIndex tile)
|
|
|
|
{
|
|
|
|
assert(tile < MapSize());
|
|
|
|
return (TropicZone)GB(_m[tile].extra, 0, 2);
|
|
|
|
}
|
2005-09-18 20:56:44 +00:00
|
|
|
#endif /* TILE_H */
|