road_map.cpp

Go to the documentation of this file.
00001 /* $Id: road_map.cpp 12390 2008-03-22 10:56:08Z rubidium $ */
00002 
00005 #include "stdafx.h"
00006 #include "openttd.h"
00007 #include "bridge_map.h"
00008 #include "tile_cmd.h"
00009 #include "road_map.h"
00010 #include "station.h"
00011 #include "tunnel_map.h"
00012 #include "station_map.h"
00013 #include "depot.h"
00014 #include "tunnelbridge_map.h"
00015 
00016 
00017 RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
00018 {
00019   if (!HasTileRoadType(tile, rt)) return ROAD_NONE;
00020 
00021   switch (GetTileType(tile)) {
00022     case MP_ROAD:
00023       switch (GetRoadTileType(tile)) {
00024         default:
00025         case ROAD_TILE_NORMAL:   return GetRoadBits(tile, rt);
00026         case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile);
00027         case ROAD_TILE_DEPOT:    return DiagDirToRoadBits(GetRoadDepotDirection(tile));
00028       }
00029 
00030     case MP_STATION:
00031       if (!IsRoadStopTile(tile)) return ROAD_NONE;
00032       if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y;
00033       return DiagDirToRoadBits(GetRoadStopDir(tile));
00034 
00035     case MP_TUNNELBRIDGE:
00036       if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
00037       return straight_tunnel_bridge_entrance ?
00038           AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
00039           DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
00040 
00041     default: return ROAD_NONE;
00042   }
00043 }
00044 
00045 
00046 TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
00047 {
00048   /* Don't allow local authorities to build roads through road depots or road stops. */
00049   if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) {
00050     return TRACK_BIT_NONE;
00051   }
00052 
00053   return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)));
00054 }

Generated on Mon Sep 22 20:34:18 2008 for openttd by  doxygen 1.5.6