(svn r27953) -Cleanup: Adjust other languages for r27952
[openttd.git] / src / road_map.cpp
blob4984117bab168d3506c79b671d2b6579e85ecd7f
1 /* $Id$ */
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 */
10 /** @file road_map.cpp Complex road accessors. */
12 #include "stdafx.h"
13 #include "station_map.h"
14 #include "tunnelbridge_map.h"
16 #include "safeguards.h"
19 /**
20 * Returns the RoadBits on an arbitrary tile
21 * Special behaviour:
22 * - road depots: entrance is treated as road piece
23 * - road tunnels: entrance is treated as road piece
24 * - bridge ramps: start of the ramp is treated as road piece
25 * - bridge middle parts: bridge itself is ignored
27 * If straight_tunnel_bridge_entrance is set a ROAD_X or ROAD_Y
28 * for bridge ramps and tunnel entrances is returned depending
29 * on the orientation of the tunnel or bridge.
30 * @param tile the tile to get the road bits for
31 * @param rt the road type to get the road bits form
32 * @param straight_tunnel_bridge_entrance whether to return straight road bits for tunnels/bridges.
33 * @return the road bits of the given tile
35 RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
37 if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
39 switch (GetTileType(tile)) {
40 case MP_ROAD:
41 switch (GetRoadTileType(tile)) {
42 default:
43 case ROAD_TILE_NORMAL: return GetRoadBits(tile, rt);
44 case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile);
45 case ROAD_TILE_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile));
48 case MP_STATION:
49 if (!IsRoadStopTile(tile)) return ROAD_NONE;
50 if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y;
51 return DiagDirToRoadBits(GetRoadStopDir(tile));
53 case MP_TUNNELBRIDGE:
54 if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
55 return straight_tunnel_bridge_entrance ?
56 AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
57 DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
59 default: return ROAD_NONE;