2006-03-05 12:22:20 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file road_map.cpp Complex road accessors. */
|
2007-03-28 20:41:35 +00:00
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
#include "stdafx.h"
|
2006-03-31 19:10:54 +00:00
|
|
|
#include "station_map.h"
|
2007-12-16 15:38:51 +00:00
|
|
|
#include "tunnelbridge_map.h"
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
|
2008-03-22 10:56:08 +00:00
|
|
|
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
|
2006-03-05 12:22:20 +00:00
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
|
2007-05-20 19:14:08 +00:00
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
switch (GetTileType(tile)) {
|
2007-07-29 23:42:59 +00:00
|
|
|
case MP_ROAD:
|
2006-05-09 08:25:31 +00:00
|
|
|
switch (GetRoadTileType(tile)) {
|
2006-03-05 12:22:20 +00:00
|
|
|
default:
|
2007-05-20 19:14:08 +00:00
|
|
|
case ROAD_TILE_NORMAL: return GetRoadBits(tile, rt);
|
2006-05-09 08:25:31 +00:00
|
|
|
case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile);
|
|
|
|
case ROAD_TILE_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile));
|
2006-03-05 12:22:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case MP_STATION:
|
2007-01-10 18:56:51 +00:00
|
|
|
if (!IsRoadStopTile(tile)) return ROAD_NONE;
|
2007-02-14 16:37:16 +00:00
|
|
|
if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y;
|
2006-03-31 19:10:54 +00:00
|
|
|
return DiagDirToRoadBits(GetRoadStopDir(tile));
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
case MP_TUNNELBRIDGE:
|
2007-12-16 19:30:42 +00:00
|
|
|
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
|
2008-03-22 10:56:08 +00:00
|
|
|
return straight_tunnel_bridge_entrance ?
|
|
|
|
AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
|
|
|
|
DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
|
2006-03-05 12:22:20 +00:00
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
default: return ROAD_NONE;
|
2006-03-05 12:22:20 +00:00
|
|
|
}
|
|
|
|
}
|