OpenTTD: src/road_map.cpp Source File

OpenTTD

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

- File List
- Globals

road_map.cpp
Go to the documentation of this file.
1 /* $Id: road_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 "station_map.h"
14 #include "tunnelbridge_map.h"
15
16 #include "safeguards.h"
17
18
35 RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
36 {
37 if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
38
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));
46 }
47
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));
52
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)));
58
59 default: return ROAD_NONE;
60 }
61 }