2006-03-06 20:55:24 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#ifndef TUNNEL_MAP_H
|
|
|
|
#define TUNNEL_MAP_H
|
|
|
|
|
|
|
|
#include "direction.h"
|
|
|
|
#include "macros.h"
|
|
|
|
#include "map.h"
|
|
|
|
#include "rail.h"
|
|
|
|
|
|
|
|
|
2006-03-12 15:04:03 +00:00
|
|
|
static inline bool IsTunnel(TileIndex t)
|
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
2006-03-12 15:04:03 +00:00
|
|
|
return !HASBIT(_m[t].m5, 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline bool IsTunnelTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-06 20:55:24 +00:00
|
|
|
static inline DiagDirection GetTunnelDirection(TileIndex t)
|
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTunnelTile(t));
|
2006-03-06 20:55:24 +00:00
|
|
|
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static inline TransportType GetTunnelTransportType(TileIndex t)
|
|
|
|
{
|
2006-03-30 09:29:01 +00:00
|
|
|
assert(IsTunnelTile(t));
|
2006-03-06 20:55:24 +00:00
|
|
|
return (TransportType)GB(_m[t].m5, 2, 2);
|
|
|
|
}
|
|
|
|
|
2006-12-29 09:10:44 +00:00
|
|
|
static inline bool HasTunnelSnowOrDesert(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsTunnelTile(t));
|
|
|
|
return HASBIT(_m[t].m4, 7);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void SetTunnelSnowOrDesert(TileIndex t, bool snow_or_desert)
|
|
|
|
{
|
|
|
|
assert(IsTunnelTile(t));
|
|
|
|
SB(_m[t].m4, 7, 1, snow_or_desert);
|
|
|
|
}
|
|
|
|
|
2006-03-06 20:55:24 +00:00
|
|
|
|
|
|
|
TileIndex GetOtherTunnelEnd(TileIndex);
|
2006-03-07 07:51:05 +00:00
|
|
|
bool IsTunnelInWay(TileIndex, uint z);
|
2006-03-06 20:55:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d)
|
|
|
|
{
|
|
|
|
SetTileType(t, MP_TUNNELBRIDGE);
|
|
|
|
SetTileOwner(t, o);
|
|
|
|
_m[t].m2 = 0;
|
|
|
|
_m[t].m3 = 0;
|
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = TRANSPORT_ROAD << 2 | d;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
|
|
|
|
{
|
|
|
|
SetTileType(t, MP_TUNNELBRIDGE);
|
|
|
|
SetTileOwner(t, o);
|
|
|
|
_m[t].m2 = 0;
|
|
|
|
_m[t].m3 = r;
|
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = TRANSPORT_RAIL << 2 | d;
|
|
|
|
}
|
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#endif /* TUNNEL_MAP_H */
|