Rearrange storage of reserved tracks for railway tiles
[openttd/fttd.git] / src / map / tunnelbridge.h
blob8abd7319bb58a72a52b16ae3e3b3e1931b6a0ed8
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
8 /** @file map/tunnelbridge.h Miscellaneous functions for tunnel and bridge tiles. */
10 #ifndef MAP_TUNNELBRIDGE_H
11 #define MAP_TUNNELBRIDGE_H
13 #include "../stdafx.h"
14 #include "map.h"
15 #include "coord.h"
16 #include "class.h"
17 #include "tunnel.h"
18 #include "bridge.h"
20 /**
21 * Calculates the length of a tunnel or a bridge (without end tiles)
22 * @param begin The begin of the tunnel or bridge.
23 * @param end The end of the tunnel or bridge.
24 * @return length of bridge/tunnel middle
26 static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
28 return DistanceAlongAxis(begin, end) - 1;
31 /**
32 * Determines type of the wormhole and returns its other end
33 * @param t one end
34 * @pre IsTunnelTile(t) || IsBridgeHeadTile(t)
35 * @return other end
37 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
39 assert(IsTunnelTile(t) || IsBridgeHeadTile(t));
40 return IsTunnelTile(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
43 #endif /* MAP_TUNNELBRIDGE_H */