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 tunnel_map.h Map accessors for tunnels. */
|
2007-04-04 03:21:14 +00:00
|
|
|
|
2006-03-06 20:55:24 +00:00
|
|
|
#ifndef TUNNEL_MAP_H
|
|
|
|
#define TUNNEL_MAP_H
|
|
|
|
|
2009-03-02 22:57:47 +00:00
|
|
|
#include "road_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);
|
2011-11-08 19:44:41 +00:00
|
|
|
bool IsTunnelInWay(TileIndex, int z);
|
|
|
|
bool IsTunnelInWayDir(TileIndex tile, int 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
|
|
|
*/
|
2019-04-06 06:46:15 +00:00
|
|
|
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
|
2006-03-06 20:55:24 +00:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_TUNNELBRIDGE);
|
|
|
|
SetTileOwner(t, o);
|
|
|
|
_m[t].m2 = 0;
|
2009-03-02 22:57:47 +00:00
|
|
|
_m[t].m3 = 0;
|
2006-03-06 20:55:24 +00:00
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = TRANSPORT_ROAD << 2 | d;
|
2014-09-21 11:23:33 +00:00
|
|
|
SB(_me[t].m6, 2, 4, 0);
|
2009-03-08 16:10:39 +00:00
|
|
|
_me[t].m7 = 0;
|
2018-07-22 22:47:15 +00:00
|
|
|
_me[t].m8 = 0;
|
2019-04-06 06:46:15 +00:00
|
|
|
SetRoadOwner(t, RTT_ROAD, o);
|
|
|
|
if (o != OWNER_TOWN) SetRoadOwner(t, RTT_TRAM, o);
|
|
|
|
SetRoadTypes(t, road_rt, tram_rt);
|
2006-03-06 20:55:24 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2018-07-22 22:47:15 +00:00
|
|
|
_m[t].m3 = 0;
|
2006-03-06 20:55:24 +00:00
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = TRANSPORT_RAIL << 2 | d;
|
2014-09-21 11:23:33 +00:00
|
|
|
SB(_me[t].m6, 2, 4, 0);
|
2009-03-08 16:10:39 +00:00
|
|
|
_me[t].m7 = 0;
|
2018-07-22 22:47:15 +00:00
|
|
|
_me[t].m8 = r;
|
2006-03-06 20:55:24 +00:00
|
|
|
}
|
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#endif /* TUNNEL_MAP_H */
|