2006-03-23 20:47:56 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
|
|
|
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file unmovable_map.h Map accessors for unmovable tiles. */
|
2007-04-04 04:08:47 +00:00
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#ifndef UNMOVABLE_MAP_H
|
|
|
|
#define UNMOVABLE_MAP_H
|
|
|
|
|
2008-01-07 00:45:05 +00:00
|
|
|
#include "tile_map.h"
|
2010-08-02 21:35:59 +00:00
|
|
|
#include "unmovable_type.h"
|
2006-03-23 20:47:56 +00:00
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Gets the UnmovableType of the given unmovable tile
|
|
|
|
* @param t the tile to get the type from.
|
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
|
|
|
* @return the type.
|
|
|
|
*/
|
2006-03-23 20:47:56 +00:00
|
|
|
static inline UnmovableType GetUnmovableType(TileIndex t)
|
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
2007-01-10 18:56:51 +00:00
|
|
|
return (UnmovableType)_m[t].m5;
|
2006-03-23 20:47:56 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Does the given tile have a transmitter?
|
|
|
|
* @param t the tile to inspect.
|
|
|
|
* @return true if and only if the tile has a transmitter.
|
|
|
|
*/
|
2006-03-23 20:47:56 +00:00
|
|
|
static inline bool IsTransmitterTile(TileIndex t)
|
|
|
|
{
|
2007-04-18 18:20:31 +00:00
|
|
|
return IsTileType(t, MP_UNMOVABLE) && GetUnmovableType(t) == UNMOVABLE_TRANSMITTER;
|
2006-03-23 20:47:56 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Is this unmovable tile an 'owned land' tile?
|
|
|
|
* @param t the tile to inspect.
|
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
|
|
|
* @return true if and only if the tile is an 'owned land' tile.
|
|
|
|
*/
|
2006-03-23 20:47:56 +00:00
|
|
|
static inline bool IsOwnedLand(TileIndex t)
|
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
2006-03-23 20:47:56 +00:00
|
|
|
return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND;
|
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Is the given tile (pre-)owned by someone (the little flags)?
|
|
|
|
* @param t the tile to inspect.
|
|
|
|
* @return true if and only if the tile is an 'owned land' tile.
|
|
|
|
*/
|
2006-03-23 20:47:56 +00:00
|
|
|
static inline bool IsOwnedLandTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
|
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Is this unmovable tile a HQ tile?
|
|
|
|
* @param t the tile to inspect.
|
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
|
|
|
* @return true if and only if the tile is a HQ tile.
|
|
|
|
*/
|
2006-04-03 12:20:55 +00:00
|
|
|
static inline bool IsCompanyHQ(TileIndex t)
|
|
|
|
{
|
2007-04-18 18:20:31 +00:00
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
2009-01-28 19:57:23 +00:00
|
|
|
return _m[t].m5 == UNMOVABLE_HQ;
|
2006-04-03 12:20:55 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Is this unmovable tile a statue?
|
|
|
|
* @param t the tile to inspect.
|
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
|
|
|
* @return true if and only if the tile is a statue.
|
|
|
|
*/
|
2007-03-08 14:34:32 +00:00
|
|
|
static inline bool IsStatue(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
|
|
|
return GetUnmovableType(t) == UNMOVABLE_STATUE;
|
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Is the given tile a statue?
|
|
|
|
* @param t the tile to inspect.
|
|
|
|
* @return true if and only if the tile is a statue.
|
|
|
|
*/
|
2007-03-08 14:34:32 +00:00
|
|
|
static inline bool IsStatueTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_UNMOVABLE) && IsStatue(t);
|
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Get the town of the given statue tile.
|
|
|
|
* @param t the tile of the statue.
|
|
|
|
* @pre IsStatueTile(t)
|
|
|
|
* @return the town the given statue is in.
|
|
|
|
*/
|
2007-03-08 14:34:32 +00:00
|
|
|
static inline TownID GetStatueTownID(TileIndex t)
|
|
|
|
{
|
2007-04-18 18:20:31 +00:00
|
|
|
assert(IsStatueTile(t));
|
2007-03-08 14:34:32 +00:00
|
|
|
return _m[t].m2;
|
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
2010-08-03 08:16:06 +00:00
|
|
|
* Get animation stage/counter of this tile.
|
|
|
|
* @param t The tile to query.
|
2010-08-03 08:09:45 +00:00
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
2010-08-03 08:16:06 +00:00
|
|
|
* @return The animation 'stage' of the tile.
|
2007-04-18 18:20:31 +00:00
|
|
|
*/
|
2010-08-03 08:16:06 +00:00
|
|
|
static inline byte GetUnmovableAnimationStage(TileIndex t)
|
2006-04-03 12:20:55 +00:00
|
|
|
{
|
2010-08-03 08:09:45 +00:00
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
|
|
|
return GB(_m[t].m6, 2, 4);
|
2009-01-28 19:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-08-03 08:16:06 +00:00
|
|
|
* Set animation stage/counter of this tile.
|
|
|
|
* @param t The tile to query.
|
|
|
|
* @param stage The stage of this tile.
|
2010-08-03 08:09:45 +00:00
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
2009-01-28 19:57:23 +00:00
|
|
|
*/
|
2010-08-03 08:16:06 +00:00
|
|
|
static inline void SetUnmovableAnimationStage(TileIndex t, uint8 stage)
|
2009-01-28 19:57:23 +00:00
|
|
|
{
|
2010-08-03 08:09:45 +00:00
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
2010-08-03 08:16:06 +00:00
|
|
|
SB(_m[t].m6, 2, 4, stage);
|
2006-04-03 12:20:55 +00:00
|
|
|
}
|
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
2010-08-03 08:16:06 +00:00
|
|
|
* Get offset to the northern most tile.
|
|
|
|
* @param t The tile to get the offset from.
|
|
|
|
* @return The offset to the northern most tile of this structure.
|
2010-08-03 08:09:45 +00:00
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
2007-04-18 18:20:31 +00:00
|
|
|
*/
|
2010-08-03 08:16:06 +00:00
|
|
|
static inline byte GetUnmovableOffset(TileIndex t)
|
2006-04-03 12:20:55 +00:00
|
|
|
{
|
2010-08-03 08:09:45 +00:00
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
|
|
|
return _m[t].m3;
|
2009-01-28 19:57:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-08-03 08:16:06 +00:00
|
|
|
* Set offset to the northern most tile.
|
|
|
|
* @param t The tile to set the offset of.
|
|
|
|
* @param offset The offset to the northern most tile of this structure.
|
2010-08-03 08:09:45 +00:00
|
|
|
* @pre IsTileType(t, MP_UNMOVABLE)
|
2009-01-28 19:57:23 +00:00
|
|
|
*/
|
2010-08-03 08:16:06 +00:00
|
|
|
static inline void SetUnmovableOffset(TileIndex t, uint8 offset)
|
2009-01-28 19:57:23 +00:00
|
|
|
{
|
2010-08-03 08:09:45 +00:00
|
|
|
assert(IsTileType(t, MP_UNMOVABLE));
|
2010-08-03 08:16:06 +00:00
|
|
|
_m[t].m3 = offset;
|
2006-04-03 12:20:55 +00:00
|
|
|
}
|
|
|
|
|
2006-03-31 09:09:26 +00:00
|
|
|
|
2007-04-18 18:20:31 +00:00
|
|
|
/**
|
|
|
|
* Make an Unmovable tile.
|
|
|
|
* @note do not use this function directly. Use one of the other Make* functions.
|
2010-08-03 08:09:45 +00:00
|
|
|
* @param t The tile to make unmovable.
|
|
|
|
* @param u The unmovable type of the tile.
|
|
|
|
* @param o The new owner of the tile.
|
2010-08-03 08:58:12 +00:00
|
|
|
* @param offset The offset to the northern tile of this object.
|
|
|
|
* @param index Generic index associated with the object type.
|
2007-04-18 18:20:31 +00:00
|
|
|
*/
|
2010-08-03 08:58:12 +00:00
|
|
|
static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o, uint8 offset, uint index)
|
2006-03-23 20:47:56 +00:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_UNMOVABLE);
|
|
|
|
SetTileOwner(t, o);
|
2010-08-03 08:58:12 +00:00
|
|
|
_m[t].m2 = index;
|
2010-08-03 08:09:45 +00:00
|
|
|
_m[t].m3 = offset;
|
2006-03-23 20:47:56 +00:00
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = u;
|
2009-03-08 16:10:39 +00:00
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
|
|
|
_me[t].m7 = 0;
|
2006-03-23 20:47:56 +00:00
|
|
|
}
|
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#endif /* UNMOVABLE_MAP_H */
|