2009-08-21 22:21:05 +02: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 17:11:33 +02:00
|
|
|
/** @file tunnel_map.h Map accessors for tunnels. */
|
2007-04-04 05:21:14 +02:00
|
|
|
|
2006-03-06 21:55:24 +01:00
|
|
|
#ifndef TUNNEL_MAP_H
|
|
|
|
#define TUNNEL_MAP_H
|
|
|
|
|
2020-07-12 15:38:35 +02:00
|
|
|
#include "rail_map.h"
|
2009-03-02 23:57:47 +01:00
|
|
|
#include "road_map.h"
|
2006-03-06 21:55:24 +01:00
|
|
|
|
2007-12-16 16:38:51 +01:00
|
|
|
|
2007-04-27 23:29:36 +02: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)
|
|
|
|
*/
|
2024-01-06 12:19:27 +01:00
|
|
|
inline bool IsTunnel(Tile t)
|
2006-03-12 16:04:03 +01:00
|
|
|
{
|
2006-03-30 11:29:01 +02:00
|
|
|
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
2023-01-21 16:40:28 +01:00
|
|
|
return !HasBit(t.m5(), 7);
|
2006-03-12 16:04:03 +01:00
|
|
|
}
|
|
|
|
|
2007-04-27 23:29:36 +02: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)
|
|
|
|
*/
|
2024-01-06 12:19:27 +01:00
|
|
|
inline bool IsTunnelTile(Tile t)
|
2006-03-12 16:04:03 +01:00
|
|
|
{
|
|
|
|
return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
|
|
|
|
}
|
|
|
|
|
2006-03-06 21:55:24 +01:00
|
|
|
TileIndex GetOtherTunnelEnd(TileIndex);
|
2011-11-08 20:44:41 +01:00
|
|
|
bool IsTunnelInWay(TileIndex, int z);
|
|
|
|
bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir);
|
2006-03-06 21:55:24 +01:00
|
|
|
|
2007-04-27 23:29:36 +02: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 21:14:08 +02:00
|
|
|
* @param r the road type used in the tunnel
|
2007-04-27 23:29:36 +02:00
|
|
|
*/
|
2024-01-06 12:19:27 +01:00
|
|
|
inline void MakeRoadTunnel(Tile t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
|
2006-03-06 21:55:24 +01:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_TUNNELBRIDGE);
|
|
|
|
SetTileOwner(t, o);
|
2023-01-21 16:40:28 +01:00
|
|
|
t.m2() = 0;
|
|
|
|
t.m3() = 0;
|
|
|
|
t.m4() = 0;
|
|
|
|
t.m5() = TRANSPORT_ROAD << 2 | d;
|
|
|
|
SB(t.m6(), 2, 4, 0);
|
|
|
|
t.m7() = 0;
|
|
|
|
t.m8() = 0;
|
2019-04-06 08:46:15 +02:00
|
|
|
SetRoadOwner(t, RTT_ROAD, o);
|
|
|
|
if (o != OWNER_TOWN) SetRoadOwner(t, RTT_TRAM, o);
|
|
|
|
SetRoadTypes(t, road_rt, tram_rt);
|
2006-03-06 21:55:24 +01:00
|
|
|
}
|
|
|
|
|
2007-04-27 23:29:36 +02: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
|
|
|
|
*/
|
2024-01-06 12:19:27 +01:00
|
|
|
inline void MakeRailTunnel(Tile t, Owner o, DiagDirection d, RailType r)
|
2006-03-06 21:55:24 +01:00
|
|
|
{
|
|
|
|
SetTileType(t, MP_TUNNELBRIDGE);
|
|
|
|
SetTileOwner(t, o);
|
2023-01-21 16:40:28 +01:00
|
|
|
t.m2() = 0;
|
|
|
|
t.m3() = 0;
|
|
|
|
t.m4() = 0;
|
|
|
|
t.m5() = TRANSPORT_RAIL << 2 | d;
|
|
|
|
SB(t.m6(), 2, 4, 0);
|
|
|
|
t.m7() = 0;
|
|
|
|
t.m8() = 0;
|
2020-07-12 15:38:35 +02:00
|
|
|
SetRailType(t, r);
|
|
|
|
SetRoadTypes(t, INVALID_ROADTYPE, INVALID_ROADTYPE);
|
2006-03-06 21:55:24 +01:00
|
|
|
}
|
|
|
|
|
2006-09-28 20:42:35 +02:00
|
|
|
#endif /* TUNNEL_MAP_H */
|