OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

bridge_map.cpp
Go to the documentation of this file.
1 /* $Id: bridge_map.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
9
12 #include "stdafx.h"
13 #include "landscape.h"
14 #include "tunnelbridge_map.h"
15
16 #include "safeguards.h"
17
18
24 static TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
25 {
26 TileIndexDiff delta = TileOffsByDiagDir(dir);
27
28 dir = ReverseDiagDir(dir);
29 do {
30 tile += delta;
31 } while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(tile) != dir);
32
33 return tile;
34 }
35
36
41 TileIndex GetNorthernBridgeEnd(TileIndex t)
42 {
43 return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t))));
44 }
45
46
51 TileIndex GetSouthernBridgeEnd(TileIndex t)
52 {
53 return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t)));
54 }
55
56
61 TileIndex GetOtherBridgeEnd(TileIndex tile)
62 {
63 assert(IsBridgeTile(tile));
64 return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
65 }
66
72 int GetBridgeHeight(TileIndex t)
73 {
74 int h;
75 Slope tileh = GetTileSlope(t, &h);
76 Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
77
78 /* one height level extra for the ramp */
79 return h + 1 + ApplyFoundationToSlope(f, &tileh);
80 }