Go to the documentation of this file.
1 /* $Id: bridge_map.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
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 <>.
8  */
12 #include "stdafx.h"
13 #include "landscape.h"
14 #include "tunnelbridge_map.h"
16 #include "safeguards.h"
25 {
26  TileIndexDiff delta = TileOffsByDiagDir(dir);
28  dir = ReverseDiagDir(dir);
29  do {
30  tile += delta;
31  } while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(tile) != dir);
33  return tile;
34 }
42 {
44 }
52 {
54 }
62 {
63  assert(IsBridgeTile(tile));
64  return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
65 }
73 {
74  int h;
75  Slope tileh = GetTileSlope(t, &h);
78  /* one height level extra for the ramp */
79  return h + 1 + ApplyFoundationToSlope(f, &tileh);
80 }
TileIndex GetOtherBridgeEnd(TileIndex tile)
Starting at one bridge end finds the other bridge end.
Definition: bridge_map.cpp:61
uint ApplyFoundationToSlope(Foundation f, Slope *s)
Applies a foundation to a slope.
Definition: landscape.cpp:99
int32 TileIndexDiff
An offset value between to tiles.
Definition: map_func.h:156
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
int GetBridgeHeight(TileIndex t)
Get the height (&#39;z&#39;) of a bridge.
Definition: bridge_map.cpp:72
TileIndex GetNorthernBridgeEnd(TileIndex t)
Finds the northern end of a bridge starting at a middle tile.
Definition: bridge_map.cpp:41
Slope GetTileSlope(TileIndex tile, int *h)
Return the slope of a given tile inside the map.
Definition: tile_map.cpp:115
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:343
Enumeration for Foundations.
Definition: slope_type.h:95
Foundation GetBridgeFoundation(Slope tileh, Axis axis)
Get the foundation for a bridge.
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
Enumeration for diagonal directions.
TileIndex GetSouthernBridgeEnd(TileIndex t)
Finds the southern end of a bridge starting at a middle tile.
Definition: bridge_map.cpp:51
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
static TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
Finds the end of a bridge in the specified direction starting at a middle tile.
Definition: bridge_map.cpp:24
static Axis GetBridgeAxis(TileIndex t)
Get the axis of the bridge that goes over the tile.
Definition: bridge_map.h:68
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
Enumeration for the slope-type.
Definition: slope_type.h:50
Functions related to OTTD&#39;s landscape.
Functions that have tunnels and bridges in common.
static DiagDirection AxisToDiagDir(Axis a)
Converts an Axis to a DiagDirection.