src/road_map.cpp
author translators
Fri, 28 Nov 2008 18:47:49 +0000
changeset 10389 05465e8a465c
parent 9111 48ce04029fe4
permissions -rw-r--r--
(svn r14640) -Update: WebTranslator2 update to 2008-11-28 18:47:35
bulgarian - 1 fixed by Ar4i (1)
catalan - 1 fixed by arnaullv (1)
croatian - 43 fixed by knovak (43)
esperanto - 3 fixed by Athaba (3)
estonian - 8 fixed by t2t2 (8)
german - 1 fixed by Athaba (1)
latvian - 315 fixed, 112 changed by Reinis (414), yopzer (7), niko (6)
polish - 1 fixed by xaxa (1)
romanian - 6 fixed, 1 changed by kkmic (7)
ukrainian - 2 fixed by mad (2)
/* $Id$ */

/** @file road_map.cpp Complex road accessors. */

#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
#include "tile_cmd.h"
#include "road_map.h"
#include "tunnel_map.h"
#include "station_map.h"
#include "tunnelbridge_map.h"


RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance)
{
	if (!HasTileRoadType(tile, rt)) return ROAD_NONE;

	switch (GetTileType(tile)) {
		case MP_ROAD:
			switch (GetRoadTileType(tile)) {
				default:
				case ROAD_TILE_NORMAL:   return GetRoadBits(tile, rt);
				case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile);
				case ROAD_TILE_DEPOT:    return DiagDirToRoadBits(GetRoadDepotDirection(tile));
			}

		case MP_STATION:
			if (!IsRoadStopTile(tile)) return ROAD_NONE;
			if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y;
			return DiagDirToRoadBits(GetRoadStopDir(tile));

		case MP_TUNNELBRIDGE:
			if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
			return straight_tunnel_bridge_entrance ?
					AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
					DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));

		default: return ROAD_NONE;
	}
}


TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
{
	/* Don't allow local authorities to build roads through road depots or road stops. */
	if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) {
		return TRACK_BIT_NONE;
	}

	return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)));
}