|
|
|
@ -30,7 +30,7 @@
|
|
|
|
|
*/
|
|
|
|
|
static inline uint TileHeight(TileIndex tile)
|
|
|
|
|
{
|
|
|
|
|
assert(tile < MapSize());
|
|
|
|
|
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
|
|
|
|
|
return _m[tile].height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -48,7 +48,7 @@ uint TileHeightOutsideMap(int x, int y);
|
|
|
|
|
*/
|
|
|
|
|
static inline void SetTileHeight(TileIndex tile, uint height)
|
|
|
|
|
{
|
|
|
|
|
assert(tile < MapSize());
|
|
|
|
|
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
|
|
|
|
|
assert(height <= MAX_TILE_HEIGHT);
|
|
|
|
|
_m[tile].height = height;
|
|
|
|
|
}
|
|
|
|
@ -88,7 +88,7 @@ static inline uint TilePixelHeightOutsideMap(int x, int y)
|
|
|
|
|
*/
|
|
|
|
|
static inline TileType GetTileType(TileIndex tile)
|
|
|
|
|
{
|
|
|
|
|
assert(tile < MapSize());
|
|
|
|
|
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
|
|
|
|
|
return (TileType)GB(_m[tile].type, 4, 4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -101,7 +101,7 @@ static inline TileType GetTileType(TileIndex tile)
|
|
|
|
|
*/
|
|
|
|
|
static inline bool IsInnerTile(TileIndex tile)
|
|
|
|
|
{
|
|
|
|
|
assert(tile < MapSize());
|
|
|
|
|
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
|
|
|
|
|
|
|
|
|
|
uint x = TileX(tile);
|
|
|
|
|
uint y = TileY(tile);
|
|
|
|
@ -123,11 +123,11 @@ static inline bool IsInnerTile(TileIndex tile)
|
|
|
|
|
*/
|
|
|
|
|
static inline void SetTileType(TileIndex tile, TileType type)
|
|
|
|
|
{
|
|
|
|
|
assert(tile < MapSize());
|
|
|
|
|
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
|
|
|
|
|
/* VOID tiles (and no others) are exactly allowed at the lower left and right
|
|
|
|
|
* edges of the map. If _settings_game.construction.freeform_edges is true,
|
|
|
|
|
* the upper edges of the map are also VOID tiles. */
|
|
|
|
|
assert(IsInnerTile(tile) == (type != MP_VOID));
|
|
|
|
|
assert_msg(IsInnerTile(tile) == (type != MP_VOID), "tile: 0x%X (%d), type: %d", tile, IsInnerTile(tile), type);
|
|
|
|
|
SB(_m[tile].type, 4, 4, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -170,9 +170,8 @@ static inline bool IsValidTile(TileIndex tile)
|
|
|
|
|
*/
|
|
|
|
|
static inline Owner GetTileOwner(TileIndex tile)
|
|
|
|
|
{
|
|
|
|
|
assert(IsValidTile(tile));
|
|
|
|
|
assert(!IsTileType(tile, MP_HOUSE));
|
|
|
|
|
assert(!IsTileType(tile, MP_INDUSTRY));
|
|
|
|
|
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X", tile, MapSize());
|
|
|
|
|
assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d)", tile, GetTileType(tile));
|
|
|
|
|
|
|
|
|
|
return (Owner)GB(_m[tile].m1, 0, 5);
|
|
|
|
|
}
|
|
|
|
@ -190,9 +189,8 @@ static inline Owner GetTileOwner(TileIndex tile)
|
|
|
|
|
*/
|
|
|
|
|
static inline void SetTileOwner(TileIndex tile, Owner owner)
|
|
|
|
|
{
|
|
|
|
|
assert(IsValidTile(tile));
|
|
|
|
|
assert(!IsTileType(tile, MP_HOUSE));
|
|
|
|
|
assert(!IsTileType(tile, MP_INDUSTRY));
|
|
|
|
|
assert_msg(IsValidTile(tile), "tile: 0x%X, size: 0x%X, owner: %d", tile, MapSize(), owner);
|
|
|
|
|
assert_msg(!IsTileType(tile, MP_HOUSE) && !IsTileType(tile, MP_INDUSTRY), "tile: 0x%X (%d), owner: %d", tile, GetTileType(tile), owner);
|
|
|
|
|
|
|
|
|
|
SB(_m[tile].m1, 0, 5, owner);
|
|
|
|
|
}
|
|
|
|
@ -217,8 +215,8 @@ static inline bool IsTileOwner(TileIndex tile, Owner owner)
|
|
|
|
|
*/
|
|
|
|
|
static inline void SetTropicZone(TileIndex tile, TropicZone type)
|
|
|
|
|
{
|
|
|
|
|
assert(tile < MapSize());
|
|
|
|
|
assert(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL);
|
|
|
|
|
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X, type: %d", tile, MapSize(), type);
|
|
|
|
|
assert_msg(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL, "tile: 0x%X (%d), type: %d", tile, GetTileType(tile), type);
|
|
|
|
|
SB(_m[tile].type, 0, 2, type);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -230,19 +228,19 @@ static inline void SetTropicZone(TileIndex tile, TropicZone type)
|
|
|
|
|
*/
|
|
|
|
|
static inline TropicZone GetTropicZone(TileIndex tile)
|
|
|
|
|
{
|
|
|
|
|
assert(tile < MapSize());
|
|
|
|
|
assert_msg(tile < MapSize(), "tile: 0x%X, size: 0x%X", tile, MapSize());
|
|
|
|
|
return (TropicZone)GB(_m[tile].type, 0, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the current animation frame
|
|
|
|
|
* @param t the tile
|
|
|
|
|
* @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)
|
|
|
|
|
* @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION)
|
|
|
|
|
* @return frame number
|
|
|
|
|
*/
|
|
|
|
|
static inline byte GetAnimationFrame(TileIndex t)
|
|
|
|
|
{
|
|
|
|
|
assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
|
|
|
|
|
assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
|
|
|
|
|
return _me[t].m7;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -250,11 +248,11 @@ static inline byte GetAnimationFrame(TileIndex t)
|
|
|
|
|
* Set a new animation frame
|
|
|
|
|
* @param t the tile
|
|
|
|
|
* @param frame the new frame number
|
|
|
|
|
* @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)
|
|
|
|
|
* @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION)
|
|
|
|
|
*/
|
|
|
|
|
static inline void SetAnimationFrame(TileIndex t, byte frame)
|
|
|
|
|
{
|
|
|
|
|
assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
|
|
|
|
|
assert_msg(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_STATION), "tile: 0x%X (%d)", t, GetTileType(t));
|
|
|
|
|
_me[t].m7 = frame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|