# road_map.cpp

Go to the documentation of this file.

    00001 /* $Id: road_map.cpp 15299 2009-01-31 20:16:06Z smatz $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "station_map.h"
    00007 #include "tunnelbridge_map.h"
    00008
    00009
    00010 RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
    00011 {
    00012   if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
    00013
    00014   switch (GetTileType(tile)) {
    00015     case MP_ROAD:
    00016       switch (GetRoadTileType(tile)) {
    00017         default:
    00018         case ROAD_TILE_NORMAL:   return GetRoadBits(tile, rt);
    00019         case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile);
    00020         case ROAD_TILE_DEPOT:    return DiagDirToRoadBits(GetRoadDepotDirection(tile));
    00021       }
    00022
    00023     case MP_STATION:
    00024       if (!IsRoadStopTile(tile)) return ROAD_NONE;
    00025       if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y;
    00026       return DiagDirToRoadBits(GetRoadStopDir(tile));
    00027
    00028     case MP_TUNNELBRIDGE:
    00029       if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
    00030       return straight_tunnel_bridge_entrance ?
    00031           AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
    00032           DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
    00033
    00034     default: return ROAD_NONE;
    00035   }
    00036 }
    00037
    00038
    00039 TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
    00040 {
    00041   /* Don't allow local authorities to build roads through road depots or road stops. */
    00042   if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) {
    00043     return TRACK_BIT_NONE;
    00044   }
    00045
    00046   return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)));
    00047 }