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 {
|
|
|
|
TROPICZONE_INVALID = 0,
|
|
|
|
TROPICZONE_DESERT = 1,
|
|
|
|
TROPICZONE_RAINFOREST = 2,
|
|
|
|
} TropicZone;
|
2005-02-07 10:41:45 +00:00
|
|
|
|
2006-04-23 13:48:16 +00:00
|
|
|
Slope GetTileh(uint n, uint w, uint e, uint s, uint *h);
|
|
|
|
Slope GetTileSlope(TileIndex tile, uint *h);
|
2005-02-07 10:41:45 +00:00
|
|
|
uint GetTileZ(TileIndex tile);
|
2005-01-29 13:33:48 +00:00
|
|
|
|
2006-04-23 13:48:16 +00:00
|
|
|
static inline bool CorrectZ(Slope tileh)
|
2005-02-22 12:48:03 +00:00
|
|
|
{
|
|
|
|
/* 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-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)
|
|
|
|
{
|
|
|
|
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-07-13 18:04:01 +00:00
|
|
|
return 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-01-28 09:45:25 +00:00
|
|
|
/* Allow only MP_VOID to be set to border tiles. This code is put here since
|
|
|
|
* it seems there is a bug that violates this somewhere. (Formely know as
|
|
|
|
* the "old ship pf" bug, which presented a case in which this broke). It
|
|
|
|
* can be removed as soon as the bug is squashed. */
|
|
|
|
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));
|
|
|
|
|
2005-08-23 18:47:04 +00:00
|
|
|
return _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 */
|