2006-03-05 12:22:20 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-03-28 21:41:35 +01:00
|
|
|
/** @file road_map.cpp */
|
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "openttd.h"
|
2006-03-14 12:00:11 +00:00
|
|
|
#include "bridge_map.h"
|
2006-03-06 13:11:08 +00:00
|
|
|
#include "functions.h"
|
2007-04-12 14:07:15 +01:00
|
|
|
#include "landscape.h"
|
2006-03-05 12:22:20 +00:00
|
|
|
#include "road_map.h"
|
|
|
|
#include "station.h"
|
2006-03-06 20:55:24 +00:00
|
|
|
#include "tunnel_map.h"
|
2006-03-31 20:10:54 +01:00
|
|
|
#include "station_map.h"
|
2006-05-31 21:08:55 +01:00
|
|
|
#include "depot.h"
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
|
2007-05-20 20:14:08 +01:00
|
|
|
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
|
2006-03-05 12:22:20 +00:00
|
|
|
{
|
2007-11-19 21:02:30 +00:00
|
|
|
if (!HasBit(GetRoadTypes(tile), rt)) return ROAD_NONE;
|
2007-05-20 20:14:08 +01:00
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
switch (GetTileType(tile)) {
|
2007-07-30 00:42:59 +01:00
|
|
|
case MP_ROAD:
|
2006-05-09 09:25:31 +01:00
|
|
|
switch (GetRoadTileType(tile)) {
|
2006-03-05 12:22:20 +00:00
|
|
|
default:
|
2007-05-20 20:14:08 +01:00
|
|
|
case ROAD_TILE_NORMAL: return GetRoadBits(tile, rt);
|
2006-05-09 09:25:31 +01: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 20:10:54 +01:00
|
|
|
return DiagDirToRoadBits(GetRoadStopDir(tile));
|
2006-03-05 12:22:20 +00:00
|
|
|
|
|
|
|
case MP_TUNNELBRIDGE:
|
2006-12-27 12:38:02 +00:00
|
|
|
if (IsTunnel(tile)) {
|
2007-01-10 18:56:51 +00:00
|
|
|
if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
|
2006-03-06 20:55:24 +00:00
|
|
|
return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile)));
|
2006-12-27 12:38:02 +00:00
|
|
|
} else {
|
2007-01-10 18:56:51 +00:00
|
|
|
if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
|
2006-12-27 12:38:02 +00:00
|
|
|
return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(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
|
|
|
}
|
|
|
|
}
|
2006-03-06 13:11:08 +00:00
|
|
|
|
|
|
|
|
2007-05-20 20:14:08 +01:00
|
|
|
TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
|
2006-03-06 13:11:08 +00:00
|
|
|
{
|
2006-08-07 07:21:59 +01:00
|
|
|
uint32 r;
|
|
|
|
|
2007-04-03 22:51:40 +01:00
|
|
|
/* Don't allow local authorities to build roads through road depots or road stops. */
|
2007-11-19 21:02:30 +00:00
|
|
|
if ((IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasBit(GetRoadTypes(tile), rt)) {
|
2007-01-10 18:56:51 +00:00
|
|
|
return TRACK_BIT_NONE;
|
2006-05-31 21:08:55 +01:00
|
|
|
}
|
2006-08-07 07:21:59 +01:00
|
|
|
|
2007-05-24 23:41:50 +01:00
|
|
|
r = GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt));
|
2007-05-20 20:14:08 +01:00
|
|
|
|
2007-01-10 18:56:51 +00:00
|
|
|
return (TrackBits)(byte)(r | (r >> 8));
|
2006-03-06 13:11:08 +00:00
|
|
|
}
|