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/>.
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"
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;
32 * Determines type of the wormhole and returns its other end
34 * @pre IsTunnelTile(t) || IsBridgeHeadTile(t)
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 */