2006-03-06 20:55:24 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-04-04 03:21:14 +00:00
|
|
|
/** @file tunnel_map.h */
|
|
|
|
|
2006-03-06 20:55:24 +00:00
|
|
|
#ifndef TUNNEL_MAP_H
|
|
|
|
#define TUNNEL_MAP_H
|
|
|
|
|
2007-12-18 19:52:14 +00:00
|
|
|
#include "direction_func.h"
|
2007-12-18 20:38:16 +00:00
|
|
|
#include "rail_type.h"
|
|
|
|
#include "road_type.h"
|
2007-12-19 23:26:02 +00:00
|
|
|
#include "tile_map.h"
|
2006-03-06 20:55:24 +00:00
|
|
|
|
2007-12-16 15:38:51 +00:00
|
|
|
|
2007-04-27 21:29:36 +00:00
|
|
|
/**
|
|
|
|
* Is this a tunnel (entrance)?
|
|
|
|
* @param t the tile that might be a tunnel
|
|
|
|
* @pre IsTileType(t, MP_TUNNELBRIDGE)
|
|
|
|
* @return true if and only if this tile is a tunnel (entrance)
|
|
|
|
*/
|
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));
|
2007-11-19 21:02:30 +00:00
|
|
|
return !HasBit(_m[t].m5, 7);
|
2006-03-12 15:04:03 +00:00
|
|
|
}
|
|
|
|
|
2007-04-27 21:29:36 +00:00
|
|
|
/**
|
|
|
|
* Is this a tunnel (entrance)?
|
|
|
|
* @param t the tile that might be a tunnel
|
|
|
|
* @return true if and only if this tile is a tunnel (entrance)
|
|
|
|
*/
|
2006-03-12 15:04:03 +00:00
|
|
|
static inline bool IsTunnelTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
|
|
|
|
}
|
|
|
|
|
2006-03-06 20:55:24 +00:00
|
|
|
TileIndex GetOtherTunnelEnd(TileIndex);
|
2006-03-07 07:51:05 +00:00
|
|
|
bool IsTunnelInWay(TileIndex, uint z);
|
2007-06-21 17:25:17 +00:00
|
|
|
bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
|
2006-03-06 20:55:24 +00:00
|
|
|
|
2007-04-27 21:29:36 +00:00
|
|
|
/**
|
|
|
|
* Makes a road tunnel entrance
|
|
|
|
* @param t the entrance of the tunnel
|
|
|
|
* @param o the owner of the entrance
|
|
|
|
* @param d the direction facing out of the tunnel
|
2007-05-20 19:14:08 +00:00
|
|
|
* @param r the road type used in the tunnel
|
2007-04-27 21:29:36 +00:00
|
|
|
*/
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
|
2006-03-06 20:55:24 +00:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_TUNNELBRIDGE);
|
|
|
|
SetTileOwner(t, o);
|
|
|
|
_m[t].m2 = 0;
|
2007-05-20 19:14:08 +00:00
|
|
|
_m[t].m3 = r;
|
2006-03-06 20:55:24 +00:00
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = TRANSPORT_ROAD << 2 | d;
|
|
|
|
}
|
|
|
|
|
2007-04-27 21:29:36 +00:00
|
|
|
/**
|
|
|
|
* Makes a rail tunnel entrance
|
|
|
|
* @param t the entrance of the tunnel
|
|
|
|
* @param o the owner of the entrance
|
|
|
|
* @param d the direction facing out of the tunnel
|
|
|
|
* @param r the rail type used in the tunnel
|
|
|
|
*/
|
2006-03-06 20:55:24 +00:00
|
|
|
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 */
|