Changeset - r8083:8cd2123a0c7c
[Not reviewed]
master
0 27 1
smatz - 16 years ago 2007-12-16 15:38:51
smatz@openttd.org
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
28 files changed with 245 insertions and 241 deletions:
0 comments (0 inline, 0 general)
projects/openttd.vcproj
Show inline comments
 
@@ -1195,12 +1195,15 @@
 
				RelativePath=".\..\src\tunnel_map.cpp">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tunnel_map.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tunnelbridge_map.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\unmovable_map.h">
 
			</File>
 
			<File
 
				RelativePath=".\..\src\void_map.h">
 
			</File>
 
			<File
projects/openttd_vs80.vcproj
Show inline comments
 
@@ -1813,12 +1813,16 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tunnel_map.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tunnelbridge_map.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\unmovable_map.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\void_map.h"
 
				>
projects/openttd_vs90.vcproj
Show inline comments
 
@@ -1810,12 +1810,16 @@
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tunnel_map.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\tunnelbridge_map.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\unmovable_map.h"
 
				>
 
			</File>
 
			<File
 
				RelativePath=".\..\src\void_map.h"
 
				>
source.list
Show inline comments
 
@@ -370,12 +370,13 @@ road_map.cpp
 
road_map.h
 
station_map.h
 
town_map.h
 
tree_map.h
 
tunnel_map.cpp
 
tunnel_map.h
 
tunnelbridge_map.h
 
unmovable_map.h
 
void_map.h
 
water_map.h
 

	
 
# Misc
 
misc/array.hpp
src/ai/default/default.cpp
Show inline comments
 
@@ -25,14 +25,16 @@
 
#include "../../airport.h"
 
#include "../../depot.h"
 
#include "../../variables.h"
 
#include "../../bridge.h"
 
#include "../../date.h"
 
#include "../../helpers.hpp"
 
#include "../../tunnelbridge_map.h"
 
#include "default.h"
 

	
 

	
 
// remove some day perhaps?
 
static uint _ai_service_interval;
 

	
 
typedef void AiStateAction(Player *p);
 

	
 
enum {
 
@@ -2230,13 +2232,13 @@ static bool AiRemoveTileAndGoForward(Pla
 
				return false;
 
			p->ai.cur_tile_a = TILE_MASK(_build_tunnel_endtile - TileOffsByDiagDir(p->ai.cur_dir_a));
 
			return true;
 
		} else {
 
			// Check if the bridge points in the right direction.
 
			// This is not really needed the first place AiRemoveTileAndGoForward is called.
 
			if (DiagDirToAxis(GetBridgeRampDirection(tile)) != (p->ai.cur_dir_a & 1)) return false;
 
			if (DiagDirToAxis(GetTunnelBridgeDirection(tile)) != (p->ai.cur_dir_a & 1)) return false;
 

	
 
			tile = GetOtherBridgeEnd(tile);
 

	
 
			tilenew = TILE_MASK(tile - TileOffsByDiagDir(p->ai.cur_dir_a));
 
			// And clear the bridge.
 
			if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR)))
 
@@ -3730,19 +3732,19 @@ pos_3:
 
				DC_EXEC,
 
				CMD_REMOVE_ROAD);
 
		}
 
	} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		if (!IsTileOwner(tile, _current_player) ||
 
				!IsBridge(tile) ||
 
				GetBridgeTransportType(tile) != TRANSPORT_RAIL) {
 
				GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) {
 
			return;
 
		}
 

	
 
		rails = TRACK_BIT_NONE;
 

	
 
		switch (GetBridgeRampDirection(tile)) {
 
		switch (GetTunnelBridgeDirection(tile)) {
 
			default:
 
			case DIAGDIR_NE: goto pos_2;
 
			case DIAGDIR_SE: goto pos_3;
 
			case DIAGDIR_SW: goto pos_0;
 
			case DIAGDIR_NW: goto pos_1;
 
		}
src/ai/trolly/pathfinder.cpp
Show inline comments
 
@@ -9,14 +9,16 @@
 
#include "../../tile.h"
 
#include "../../command.h"
 
#include "trolly.h"
 
#include "../../depot.h"
 
#include "../../tunnel_map.h"
 
#include "../../bridge.h"
 
#include "../../tunnelbridge_map.h"
 
#include "../ai.h"
 

	
 

	
 
#define TEST_STATION_NO_DIR 0xFF
 

	
 
// Tests if a station can be build on the given spot
 
// TODO: make it train compatible
 
static bool TestCanBuildStationHere(TileIndex tile, byte dir)
 
{
 
@@ -41,14 +43,14 @@ static bool TestCanBuildStationHere(Tile
 
static bool IsRoad(TileIndex tile)
 
{
 
	return
 
		// MP_ROAD, but not a road depot?
 
		(IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
 
		(IsTileType(tile, MP_TUNNELBRIDGE) && (
 
			(IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) ||
 
			(IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_ROAD)
 
			(IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) ||
 
			(IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD)
 
		));
 
}
 

	
 

	
 
// Checks if a tile 'a' is between the tiles 'b' and 'c'
 
#define TILES_BETWEEN(a, b, c) (TileX(a) >= TileX(b) && TileX(a) <= TileX(c) && TileY(a) >= TileY(b) && TileY(a) <= TileY(c))
 
@@ -232,15 +234,15 @@ static void AyStar_AiPathFinder_GetNeigh
 
			//  We do this simply by just building the tile!
 

	
 
			// If the next step is a bridge, we have to enter it the right way
 
			if (!PathFinderInfo->rail_or_road && IsRoad(atile)) {
 
				if (IsTileType(atile, MP_TUNNELBRIDGE)) {
 
					if (IsTunnel(atile)) {
 
						if (GetTunnelDirection(atile) != i) continue;
 
						if (GetTunnelBridgeDirection(atile) != i) continue;
 
					} else {
 
						if (GetBridgeRampDirection(atile) != i) continue;
 
						if (GetTunnelBridgeDirection(atile) != i) continue;
 
					}
 
				}
 
			}
 

	
 
			if ((AI_PATHFINDER_FLAG_BRIDGE & current->path.node.user_data[0]) != 0 ||
 
					(AI_PATHFINDER_FLAG_TUNNEL & current->path.node.user_data[0]) != 0) {
src/bridge_map.cpp
Show inline comments
 
@@ -5,22 +5,23 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "bridge_map.h"
 
#include "bridge.h"
 
#include "variables.h"
 
#include "landscape.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
 
{
 
	TileIndexDiff delta = TileOffsByDiagDir(dir);
 

	
 
	dir = ReverseDiagDir(dir);
 
	do {
 
		tile += delta;
 
	} while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir);
 
	} while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(tile) != dir);
 

	
 
	return tile;
 
}
 

	
 

	
 
TileIndex GetNorthernBridgeEnd(TileIndex t)
 
@@ -35,18 +36,18 @@ TileIndex GetSouthernBridgeEnd(TileIndex
 
}
 

	
 

	
 
TileIndex GetOtherBridgeEnd(TileIndex tile)
 
{
 
	assert(IsBridgeTile(tile));
 
	return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
 
	return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
 
}
 

	
 
uint GetBridgeHeight(TileIndex t)
 
{
 
	uint h;
 
	Slope tileh = GetTileSlope(t, &h);
 
	Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
 
	Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
 

	
 
	/* one height level extra for the ramp */
 
	return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh);
 
}
src/bridge_map.h
Show inline comments
 
@@ -61,90 +61,36 @@ static inline bool MayHaveBridgeAbove(Ti
 
static inline bool IsBridgeAbove(TileIndex t)
 
{
 
	assert(MayHaveBridgeAbove(t));
 
	return GB(_m[t].m6, 6, 2) != 0;
 
}
 

	
 

	
 
/**
 
 * Determines the type of bridge on a tile
 
 * @param t The tile to analyze
 
 * @pre IsBridgeTile(t)
 
 * @return The bridge type
 
 */
 
static inline uint GetBridgeType(TileIndex t)
 
{
 
	assert(IsBridgeTile(t));
 
	return GB(_m[t].m2, 4, 4);
 
}
 

	
 

	
 
/**
 
 * Get the direction pointing onto the bridge
 
 * @param t The tile to analyze
 
 * @pre IsBridgeTile(t)
 
 * @return the above mentionned direction
 
 */
 
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
 
{
 
	assert(IsBridgeTile(t));
 
	return (DiagDirection)GB(_m[t].m5, 0, 2);
 
}
 

	
 

	
 
/**
 
 * Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
 
 * @param t The tile to analyze
 
 * @pre IsBridgeAbove(t)
 
 * @return the above mentioned axis
 
 */
 
static inline Axis GetBridgeAxis(TileIndex t)
 
{
 
	assert(IsBridgeAbove(t));
 
	return (Axis)(GB(_m[t].m6, 6, 2) - 1);
 
}
 

	
 

	
 
/**
 
 * Get the transport type of the bridge's ramp.
 
 * @param t The ramp tile to analyze
 
 * @pre IsBridgeTile(t)
 
 * @return the transport type of the bridge
 
 */
 
static inline TransportType GetBridgeTransportType(TileIndex t)
 
{
 
	assert(IsBridgeTile(t));
 
	return (TransportType)GB(_m[t].m5, 2, 2);
 
}
 

	
 

	
 
/**
 
 * Does the bridge ramp lie in a snow or desert area?
 
 * @param t The ramp tile to analyze
 
 * @pre IsBridgeTile(t)
 
 * @return true if and only if in a snow or desert area
 
 */
 
static inline bool HasBridgeSnowOrDesert(TileIndex t)
 
{
 
	assert(IsBridgeTile(t));
 
	return HasBit(_m[t].m4, 7);
 
}
 

	
 

	
 
/**
 
 * Sets whether the bridge ramp lies in a snow or desert area.
 
 * @param t              The ramp tile to set (un)make a snow/desert area
 
 * @param snow_or_desert Make (true) or unmake the tile a snow/desert area
 
 * @pre IsBridgeTile(t)
 
 */
 
static inline void SetBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
 
{
 
	assert(IsBridgeTile(t));
 
	SB(_m[t].m4, 7, 1, snow_or_desert);
 
}
 

	
 
/**
 
 * Finds the end of a bridge in the specified direction starting at a middle tile
 
 * @param t the bridge tile to find the bridge ramp for
 
 * @param d the direction to search in
 
 */
 
TileIndex GetBridgeEnd(TileIndex t, DiagDirection d);
 
@@ -184,13 +130,12 @@ uint GetBridgeHeight(TileIndex tile);
 
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
 
{
 
	assert(MayHaveBridgeAbove(t));
 
	ClrBit(_m[t].m6, 6 + a);
 
}
 

	
 

	
 
/**
 
 * Removes bridges from the given, that is bridges along the X and Y axis.
 
 * @param t the tile to remove the bridge from
 
 * @pre MayHaveBridgeAbove(t)
 
 */
 
static inline void ClearBridgeMiddle(TileIndex t)
src/elrail.cpp
Show inline comments
 
@@ -63,12 +63,14 @@
 
#include "table/sprites.h"
 
#include "table/elrail_data.h"
 
#include "vehicle.h"
 
#include "train.h"
 
#include "gui.h"
 
#include "transparency.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
static inline TLG GetTLG(TileIndex t)
 
{
 
	return (TLG)((HasBit(TileX(t), 0) << 1) + HasBit(TileY(t), 0));
 
}
 

	
 
@@ -90,20 +92,20 @@ static TrackBits GetRailTrackBitsUnivers
 
			}
 
			break;
 

	
 
		case MP_TUNNELBRIDGE:
 
			if (IsTunnel(t)) {
 
				if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
 
				if (override != NULL) *override = 1 << GetTunnelDirection(t);
 
				return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(t)));
 
				if (override != NULL) *override = 1 << GetTunnelBridgeDirection(t);
 
				return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
 
			} else {
 
				if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
 
				if (override != NULL && DistanceMax(t, GetOtherBridgeEnd(t)) > 1) {
 
					*override = 1 << GetBridgeRampDirection(t);
 
					*override = 1 << GetTunnelBridgeDirection(t);
 
				}
 
				return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(t)));
 
				return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(t)));
 
			}
 

	
 
		case MP_ROAD:
 
			if (GetRoadTileType(t) != ROAD_TILE_CROSSING) return TRACK_BIT_NONE;
 
			if (GetRailType(t) != RAILTYPE_ELECTRIC) return TRACK_BIT_NONE;
 
			return GetCrossingRailBits(t);
 
@@ -128,13 +130,13 @@ static void AdjustTileh(TileIndex tile, 
 
	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		if (IsTunnel(tile)) {
 
			*tileh = SLOPE_STEEP; // XXX - Hack to make tunnel entrances to always have a pylon
 
		} else if (*tileh != SLOPE_FLAT) {
 
			*tileh = SLOPE_FLAT;
 
		} else {
 
			switch (GetBridgeRampDirection(tile)) {
 
			switch (GetTunnelBridgeDirection(tile)) {
 
				case DIAGDIR_NE: *tileh = SLOPE_NE; break;
 
				case DIAGDIR_SE: *tileh = SLOPE_SE; break;
 
				case DIAGDIR_SW: *tileh = SLOPE_SW; break;
 
				case DIAGDIR_NW: *tileh = SLOPE_NW; break;
 
				default: NOT_REACHED();
 
			}
 
@@ -185,13 +187,13 @@ void DrawCatenaryOnTunnel(const TileInfo
 
		{ 0, 1, 16, 15 }, // SW
 
		{ 1, 0, 15, 16 }, // NW
 
	};
 

	
 
	if ((GetRailType(ti->tile) != RAILTYPE_ELECTRIC) || _patches.disable_elrails) return;
 

	
 
	DiagDirection dir = GetTunnelDirection(ti->tile);
 
	DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
 

	
 
	const SortableSpriteStruct *sss = &CatenarySpriteData_Tunnel[dir];
 
	const int *BB_data = _tunnel_wire_BB[dir];
 
	AddSortableSpriteToDraw(
 
		sss->image, PAL_NONE, ti->x + sss->x_offset, ti->y + sss->y_offset,
 
		BB_data[2] - sss->x_offset, BB_data[3] - sss->y_offset, BB_Z_SEPARATOR - sss->z_offset + 1,
 
@@ -244,13 +246,13 @@ static void DrawCatenaryRailway(const Ti
 
		int k;
 

	
 
		/* Here's one of the main headaches. GetTileSlope does not correct for possibly
 
		 * existing foundataions, so we do have to do that manually later on.*/
 
		tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL);
 
		trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
 
		if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
 
		if (IsTunnelTile(neighbour) && i != GetTunnelBridgeDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
 

	
 
		/* If the neighboured tile does not smoothly connect to the current tile (because of a foundation),
 
		 * we have to draw all pillars on the current tile. */
 
		if (GetPCPElevation(ti->tile, i) != GetPCPElevation(neighbour, ReverseDiagDir(i))) trackconfig[TS_NEIGHBOUR] = TRACK_BIT_NONE;
 

	
 
		isflat[TS_NEIGHBOUR] = ((trackconfig[TS_NEIGHBOUR] & (TRACK_BIT_HORZ | TRACK_BIT_VERT)) != 0);
 
@@ -261,13 +263,13 @@ static void DrawCatenaryRailway(const Ti
 
		/* We cycle through all the existing tracks at a PCP and see what
 
		 * PPPs we want to have, or may not have at all */
 
		for (k = 0; k < NUM_TRACKS_AT_PCP; k++) {
 
			/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */
 
			if (TrackSourceTile[i][k] == TS_NEIGHBOUR &&
 
			    IsBridgeTile(neighbour) &&
 
			    GetBridgeRampDirection(neighbour) == ReverseDiagDir(i)) {
 
			    GetTunnelBridgeDirection(neighbour) == ReverseDiagDir(i)) {
 
				continue;
 
			}
 

	
 
			/* We check whether the track in question (k) is present in the tile
 
			 * (TrackSourceTile) */
 
			if (HasBit(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) {
 
@@ -288,13 +290,13 @@ static void DrawCatenaryRailway(const Ti
 
		/* A station is always "flat", so adjust the tileh accordingly */
 
		if (IsTileType(neighbour, MP_STATION)) tileh[TS_NEIGHBOUR] = SLOPE_FLAT;
 

	
 
		/* Read the foundataions if they are present, and adjust the tileh */
 
		if (trackconfig[TS_NEIGHBOUR] != TRACK_BIT_NONE && IsTileType(neighbour, MP_RAILWAY) && GetRailType(neighbour) == RAILTYPE_ELECTRIC) foundation = GetRailFoundation(tileh[TS_NEIGHBOUR], trackconfig[TS_NEIGHBOUR]);
 
		if (IsBridgeTile(neighbour)) {
 
			foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetBridgeRampDirection(neighbour)));
 
			foundation = GetBridgeFoundation(tileh[TS_NEIGHBOUR], DiagDirToAxis(GetTunnelBridgeDirection(neighbour)));
 
		}
 

	
 
		ApplyFoundationToSlope(foundation, &tileh[TS_NEIGHBOUR]);
 

	
 
	/* Half tile slopes coincide only with horizontal/vertical track.
 
	 * Faking a flat slope results in the correct sprites on positions. */
 
@@ -440,13 +442,13 @@ void DrawCatenary(const TileInfo *ti)
 
{
 
	if (_patches.disable_elrails) return;
 

	
 
	if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile)) {
 
		TileIndex head = GetNorthernBridgeEnd(ti->tile);
 

	
 
		if (GetBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) {
 
		if (GetTunnelBridgeTransportType(head) == TRANSPORT_RAIL && GetRailType(head) == RAILTYPE_ELECTRIC) {
 
			DrawCatenaryOnBridge(ti);
 
		}
 
	}
 

	
 
	switch (GetTileType(ti->tile)) {
 
		case MP_RAILWAY:
src/npf.cpp
Show inline comments
 
@@ -16,12 +16,13 @@
 
#include "station_map.h"
 
#include "tile.h"
 
#include "depot.h"
 
#include "tunnel_map.h"
 
#include "network/network.h"
 
#include "water_map.h"
 
#include "tunnelbridge_map.h"
 

	
 
static AyStar _npf_aystar;
 

	
 
/* The cost of each trackdir. A diagonal piece is the full NPF_TILE_LENGTH,
 
 * the shorter piece is sqrt(2)/2*NPF_TILE_LENGTH =~ 0.7071
 
 */
 
@@ -167,13 +168,13 @@ static void NPFFillTrackdirChoice(AyStar
 
 * cost of that tile. If the tile is an exit, it will return the tunnel length
 
 * including the exit tile. Requires that this is a Tunnel tile */
 
static uint NPFTunnelCost(AyStarNode* current)
 
{
 
	DiagDirection exitdir = TrackdirToExitdir((Trackdir)current->direction);
 
	TileIndex tile = current->tile;
 
	if (GetTunnelDirection(tile) == ReverseDiagDir(exitdir)) {
 
	if (GetTunnelBridgeDirection(tile) == ReverseDiagDir(exitdir)) {
 
		/* We just popped out if this tunnel, since were
 
		 * facing the tunnel exit */
 
		FindLengthOfTunnelResult flotr;
 
		flotr = FindLengthOfTunnel(tile, ReverseDiagDir(exitdir));
 
		return flotr.length * NPF_TILE_LENGTH;
 
		/* @todo: Penalty for tunnels? */
 
@@ -477,14 +478,14 @@ static bool VehicleMayEnterTile(Owner ow
 
					DiagDirToAxis(enterdir) != GetCrossingRoadAxis(tile)) {
 
				return IsTileOwner(tile, owner); /* Railway needs owner check, while the street is public */
 
			}
 
			break;
 

	
 
		case MP_TUNNELBRIDGE:
 
			if ((IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) ||
 
					(IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL)) {
 
			if ((IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ||
 
					(IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL)) {
 
				return IsTileOwner(tile, owner);
 
			}
 
			break;
 

	
 
		default:
 
			break;
 
@@ -530,19 +531,19 @@ static void NPFFollowTrack(AyStar* aysta
 
	bool override_dst_check = false;
 
	/* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */
 
	aystar->num_neighbours = 0;
 
	DEBUG(npf, 4, "Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
 

	
 
	/* Find dest tile */
 
	if (IsTunnelTile(src_tile) && GetTunnelDirection(src_tile) == src_exitdir) {
 
	if (IsTunnelTile(src_tile) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
 
		/* This is a tunnel. We know this tunnel is our type,
 
		 * otherwise we wouldn't have got here. It is also facing us,
 
		 * so we should skip it's body */
 
		dst_tile = GetOtherTunnelEnd(src_tile);
 
		override_dst_check = true;
 
	} else if (IsBridgeTile(src_tile) && GetBridgeRampDirection(src_tile) == src_exitdir) {
 
	} else if (IsBridgeTile(src_tile) && GetTunnelBridgeDirection(src_tile) == src_exitdir) {
 
		dst_tile = GetOtherBridgeEnd(src_tile);
 
		override_dst_check = true;
 
	} else if (type != TRANSPORT_WATER && (IsStandardRoadStopTile(src_tile) || IsTileDepotType(src_tile, type))) {
 
		/* This is a road station (non drive-through) or a train or road depot. We can enter and exit
 
		 * those from one side only. Trackdirs don't support that (yet), so we'll
 
		 * do this here. */
 
@@ -589,15 +590,15 @@ static void NPFFollowTrack(AyStar* aysta
 
	/* I can't enter a tunnel entry/exit tile from a tile above the tunnel. Note
 
	 * that I can enter the tunnel from a tile below the tunnel entrance. This
 
	 * solves the problem of vehicles wanting to drive off a tunnel entrance */
 
	if (!override_dst_check) {
 
		if (IsTileType(dst_tile, MP_TUNNELBRIDGE)) {
 
			if (IsTunnel(dst_tile)) {
 
				if (GetTunnelDirection(dst_tile) != src_exitdir) return;
 
				if (GetTunnelBridgeDirection(dst_tile) != src_exitdir) return;
 
			} else {
 
				if (GetBridgeRampDirection(dst_tile) != src_exitdir) return;
 
				if (GetTunnelBridgeDirection(dst_tile) != src_exitdir) return;
 
			}
 
		}
 
	}
 

	
 
	/* check correct rail type (mono, maglev, etc) */
 
	if (type == TRANSPORT_RAIL) {
src/openttd.cpp
Show inline comments
 
@@ -74,12 +74,13 @@
 
#include "rail_map.h"
 
#include "road_map.h"
 
#include "water_map.h"
 
#include "industry_map.h"
 
#include "unmovable_map.h"
 
#include "tree_map.h"
 
#include "tunnelbridge_map.h"
 

	
 
#include <stdarg.h>
 

	
 
void CallLandscapeTick();
 
void IncreaseDate();
 
void DoPaletteAnimations();
 
@@ -1636,13 +1637,13 @@ bool AfterLoadGame()
 
					if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD);
 
					break;
 

	
 
				case MP_TUNNELBRIDGE:
 
					/* Middle part of "old" bridges */
 
					if (old_bridge && IsBridgeTile(t) && HasBit(_m[t].m5, 6)) break;
 
					if ((IsTunnel(t) ? GetTunnelTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetBridgeTransportType(t))) == TRANSPORT_ROAD) {
 
					if ((IsTunnel(t) ? GetTunnelBridgeTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t))) == TRANSPORT_ROAD) {
 
						SetRoadTypes(t, ROADTYPES_ROAD);
 
					}
 
					break;
 

	
 
				default: break;
 
			}
 
@@ -1696,13 +1697,13 @@ bool AfterLoadGame()
 
			}
 
		}
 

	
 
		FOR_ALL_VEHICLES(v) {
 
			if (v->type != VEH_TRAIN && v->type != VEH_ROAD) continue;
 
			if (IsBridgeTile(v->tile)) {
 
				DiagDirection dir = GetBridgeRampDirection(v->tile);
 
				DiagDirection dir = GetTunnelBridgeDirection(v->tile);
 

	
 
				if (dir != DirToDiagDir(v->direction)) continue;
 
				switch (dir) {
 
					default: NOT_REACHED();
 
					case DIAGDIR_NE: if ((v->x_pos & 0xF) !=  0)            continue; break;
 
					case DIAGDIR_SE: if ((v->y_pos & 0xF) != TILE_SIZE - 1) continue; break;
 
@@ -1754,17 +1755,17 @@ bool AfterLoadGame()
 
						SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
 
					}
 
					break;
 

	
 
				case MP_TUNNELBRIDGE:
 
					if (IsTunnel(t)) {
 
						if (GetTunnelTransportType(t) == TRANSPORT_RAIL) {
 
						if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
 
							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
 
						}
 
					} else {
 
						if (GetBridgeTransportType(t) == TRANSPORT_RAIL) {
 
						if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
 
							SetRailType(t, UpdateRailType(GetRailType(t), min_rail));
 
						}
 
					}
 
					break;
 

	
 
				default:
src/pathfind.cpp
Show inline comments
 
@@ -14,12 +14,13 @@
 
#include "pathfind.h"
 
#include "rail.h"
 
#include "debug.h"
 
#include "tunnel_map.h"
 
#include "variables.h"
 
#include "depot.h"
 
#include "tunnelbridge_map.h"
 

	
 
/* remember which tiles we have already visited so we don't visit them again. */
 
static bool TPFSetTileBit(TrackPathFinder *tpf, TileIndex tile, int dir)
 
{
 
	uint hash, val, offs;
 
	TrackPathFinderLink *link, *new_link;
 
@@ -207,13 +208,13 @@ FindLengthOfTunnelResult FindLengthOfTun
 
	dir = ReverseDiagDir(dir);
 
	do {
 
		flotr.length++;
 
		tile += delta;
 
	} while(
 
		!IsTunnelTile(tile) ||
 
		GetTunnelDirection(tile) != dir ||
 
		GetTunnelBridgeDirection(tile) != dir ||
 
		GetTileZ(tile) != z
 
	);
 

	
 
	flotr.tile = tile;
 
	return flotr;
 
}
 
@@ -257,19 +258,19 @@ static inline void TPFMode1_NormalCase(T
 
	}
 

	
 
	/* Check if the new tile is a tunnel or bridge head and that the direction
 
	 * and transport type match */
 
	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		if (IsTunnel(tile)) {
 
			if (GetTunnelDirection(tile) != direction ||
 
					GetTunnelTransportType(tile) != tpf->tracktype) {
 
			if (GetTunnelBridgeDirection(tile) != direction ||
 
					GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 
				return;
 
			}
 
		} else if (IsBridge(tile)) {
 
			if (GetBridgeRampDirection(tile) != direction ||
 
					GetBridgeTransportType(tile) != tpf->tracktype) {
 
			if (GetTunnelBridgeDirection(tile) != direction ||
 
					GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 
				return;
 
			}
 
		}
 
	}
 

	
 
	tpf->rd.cur_length++;
 
@@ -304,29 +305,29 @@ static inline void TPFMode1_NormalCase(T
 
static void TPFMode1(TrackPathFinder* tpf, TileIndex tile, DiagDirection direction)
 
{
 
	TileIndex tile_org = tile;
 

	
 
	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		if (IsTunnel(tile)) {
 
			if (GetTunnelTransportType(tile) != tpf->tracktype) {
 
			if (GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 
				return;
 
			}
 
			/* Only skip through the tunnel if heading inwards. We can
 
			 * be headed outwards if our starting position was in a
 
			 * tunnel and we're pathfinding backwards */
 
			if (GetTunnelDirection(tile) == direction) {
 
			if (GetTunnelBridgeDirection(tile) == direction) {
 
				tile = SkipToEndOfTunnel(tpf, tile, direction);
 
			} else if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
 
			} else if (GetTunnelBridgeDirection(tile) != ReverseDiagDir(direction)) {
 
				/* We don't support moving through the sides of a tunnel
 
				 * entrance :-) */
 
				return;
 
			}
 
		} else {
 
			TileIndex tile_end;
 
			if (GetBridgeRampDirection(tile) != direction ||
 
					GetBridgeTransportType(tile) != tpf->tracktype) {
 
			if (GetTunnelBridgeDirection(tile) != direction ||
 
					GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 
				return;
 
			}
 
			//fprintf(stderr, "%s: Planning over bridge\n", __func__);
 
			// TODO doesn't work - WHAT doesn't work?
 
			TPFSetTileBit(tpf, tile, 14);
 
			tile_end = GetOtherBridgeEnd(tile);
 
@@ -719,18 +720,18 @@ callback_and_continue:
 

	
 
start_at:
 
		/* If the tile is the entry tile of a tunnel, and we're not going out of the tunnel,
 
		 *   need to find the exit of the tunnel. */
 
		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
			if (IsTunnel(tile)) {
 
				if (GetTunnelDirection(tile) != ReverseDiagDir(direction)) {
 
				if (GetTunnelBridgeDirection(tile) != ReverseDiagDir(direction)) {
 
					FindLengthOfTunnelResult flotr;
 

	
 
					/* We are not just driving out of the tunnel */
 
					if (GetTunnelDirection(tile) != direction ||
 
							GetTunnelTransportType(tile) != tpf->tracktype) {
 
					if (GetTunnelBridgeDirection(tile) != direction ||
 
							GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 
						/* We are not driving into the tunnel, or it is an invalid tunnel */
 
						continue;
 
					}
 
					if (!HasBit(tpf->railtypes, GetRailType(tile))) {
 
						bits = TRACK_BIT_NONE;
 
						break;
 
@@ -739,16 +740,16 @@ start_at:
 
					si.cur_length += flotr.length * DIAG_FACTOR;
 
					tile = flotr.tile;
 
					/* tile now points to the exit tile of the tunnel */
 
				}
 
			} else {
 
				TileIndex tile_end;
 
				if (GetBridgeRampDirection(tile) != ReverseDiagDir(direction)) {
 
				if (GetTunnelBridgeDirection(tile) != ReverseDiagDir(direction)) {
 
					/* We are not just leaving the bridge */
 
					if (GetBridgeRampDirection(tile) != direction ||
 
							GetBridgeTransportType(tile) != tpf->tracktype) {
 
					if (GetTunnelBridgeDirection(tile) != direction ||
 
							GetTunnelBridgeTransportType(tile) != tpf->tracktype) {
 
						/* Not entering the bridge or not compatible */
 
						continue;
 
					}
 
				}
 
				tile_end = GetOtherBridgeEnd(tile);
 
				si.cur_length += DistanceManhattan(tile, tile_end) * DIAG_FACTOR;
src/rail.cpp
Show inline comments
 
@@ -5,12 +5,14 @@
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "bridge_map.h"
 
#include "rail.h"
 
#include "station_map.h"
 
#include "tunnel_map.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
/* XXX: Below 3 tables store duplicate data. Maybe remove some? */
 
/* Maps a trackdir to the bit that stores its status in the map arrays, in the
 
 * direction along with the trackdir */
 
extern const byte _signal_along_trackdir[] = {
 
	0x8, 0x8, 0x8, 0x2, 0x4, 0x1, 0, 0,
 
@@ -128,15 +130,15 @@ RailType GetTileRailType(TileIndex tile)
 
		case MP_STATION:
 
			if (IsRailwayStationTile(tile)) return GetRailType(tile);
 
			break;
 

	
 
		case MP_TUNNELBRIDGE:
 
			if (IsTunnel(tile)) {
 
				if (GetTunnelTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
 
				if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
 
			} else {
 
				if (GetBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
 
				if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) return GetRailType(tile);
 
			}
 
			break;
 

	
 
		default:
 
			break;
 
	}
src/rail_cmd.cpp
Show inline comments
 
@@ -39,12 +39,14 @@
 
#include "newgrf_station.h"
 
#include "train.h"
 
#include "misc/autoptr.hpp"
 
#include "autoslope.h"
 
#include "transparency.h"
 
#include "water.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
const byte _track_sloped_sprites[14] = {
 
	14, 15, 22, 13,
 
	 0, 21, 17, 12,
 
	23,  0, 18, 20,
 
	19, 16
 
@@ -924,18 +926,18 @@ static bool CheckSignalAutoFill(TileInde
 
			return true;
 

	
 
		case MP_TUNNELBRIDGE: {
 
			TileIndex orig_tile = tile;
 
			/* Skip to end of tunnel or bridge */
 
			if (IsBridge(tile)) {
 
				if (GetBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
 
				if (GetBridgeRampDirection(tile) != TrackdirToExitdir(trackdir)) return false;
 
				if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
 
				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(trackdir)) return false;
 
				tile = GetOtherBridgeEnd(tile);
 
			} else {
 
				if (GetTunnelTransportType(tile) != TRANSPORT_RAIL) return false;
 
				if (GetTunnelDirection(tile) != TrackdirToExitdir(trackdir)) return false;
 
				if (GetTunnelBridgeTransportType(tile) != TRANSPORT_RAIL) return false;
 
				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(trackdir)) return false;
 
				tile = GetOtherTunnelEnd(tile);
 
			}
 
			signal_ctr += 2 + DistanceMax(orig_tile, tile) * 2;
 
			return true;
 
		}
 

	
src/rail_gui.cpp
Show inline comments
 
@@ -29,12 +29,14 @@
 

	
 
#include "bridge_map.h"
 
#include "rail_map.h"
 
#include "road_map.h"
 
#include "station_map.h"
 
#include "tunnel_map.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
static RailType _cur_railtype;
 
static bool _remove_button_clicked;
 
static DiagDirection _build_depot_direction;
 
static byte _waypoint_count = 1;
 
static byte _cur_waypoint_type;
 
@@ -1520,14 +1522,14 @@ void SetDefaultRailGui()
 
			RailType count[RAILTYPE_END];
 
			memset(count, 0, sizeof(count));
 
			for (TileIndex t = 0; t < MapSize(); t++) {
 
				if (IsTileType(t, MP_RAILWAY) ||
 
						IsLevelCrossingTile(t) ||
 
						IsRailwayStationTile(t) ||
 
						(IsTunnelTile(t) && GetTunnelTransportType(t) == TRANSPORT_RAIL) ||
 
						(IsBridgeTile(t) && GetBridgeTransportType(t) == TRANSPORT_RAIL)
 
						(IsTunnelTile(t) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) ||
 
						(IsBridgeTile(t) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)
 
						) {
 
					count[GetRailType(t)]++;
 
				}
 
			}
 

	
 
			rt = RAILTYPE_RAIL;
src/road_cmd.cpp
Show inline comments
 
@@ -31,12 +31,14 @@
 
#include "newgrf.h"
 
#include "station_map.h"
 
#include "tunnel_map.h"
 
#include "misc/autoptr.hpp"
 
#include "autoslope.h"
 
#include "transparency.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
#define M(x) (1 << (x))
 
/* Level crossings may only be built on these slopes */
 
static const uint32 VALID_LEVEL_CROSSING_SLOPES = (M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT));
 
#undef M
 

	
 
@@ -130,16 +132,16 @@ CommandCost CmdRemoveRoad(TileIndex tile
 
			break;
 

	
 
		case MP_TUNNELBRIDGE:
 
			{
 
				TileIndex endtile;
 
				if (IsTunnel(tile)) {
 
					if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					endtile = GetOtherTunnelEnd(tile);
 
				} else {
 
					if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					endtile = GetOtherBridgeEnd(tile);
 
				}
 

	
 
				if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR;
 
			} break;
 

	
 
@@ -172,13 +174,13 @@ CommandCost CmdRemoveRoad(TileIndex tile
 
				SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
 

	
 
				/* Mark tiles diry that have been repaved */
 
				MarkTileDirtyByTile(tile);
 
				MarkTileDirtyByTile(other_end);
 
				if (IsBridge(tile)) {
 
					TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
 
					TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
 

	
 
					for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
 
				}
 
			}
 
		} else {
 
			cost.AddCost(_price.remove_road);
 
@@ -511,16 +513,16 @@ CommandCost CmdBuildRoad(TileIndex tile,
 
			break;
 

	
 
		case MP_TUNNELBRIDGE:
 
			{
 
				TileIndex endtile;
 
				if (IsTunnel(tile)) {
 
					if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					endtile = GetOtherTunnelEnd(tile);
 
				} else {
 
					if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return CMD_ERROR;
 
					endtile = GetOtherBridgeEnd(tile);
 
				}
 
				if (HasBit(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
 
				/* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */
 
				if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR;
 
			} break;
 
@@ -573,13 +575,13 @@ do_clear:;
 
				SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
 

	
 
				/* Mark tiles diry that have been repaved */
 
				MarkTileDirtyByTile(other_end);
 
				MarkTileDirtyByTile(tile);
 
				if (IsBridge(tile)) {
 
					TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
 
					TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
 

	
 
					for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
 
				}
 
			} break;
 

	
 
			case MP_STATION:
 
@@ -688,18 +690,18 @@ CommandCost CmdBuildLongRoad(TileIndex e
 
			_error_message = INVALID_STRING_ID;
 
		} else {
 
			had_success = true;
 
			/* Only pay for the upgrade on one side of the bridges and tunnels */
 
			if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
				if (IsBridge(tile)) {
 
					if ((!had_bridge || GetBridgeRampDirection(tile) == DIAGDIR_SE || GetBridgeRampDirection(tile) == DIAGDIR_SW)) {
 
					if ((!had_bridge || GetTunnelBridgeDirection(tile) == DIAGDIR_SE || GetTunnelBridgeDirection(tile) == DIAGDIR_SW)) {
 
						cost.AddCost(ret);
 
					}
 
					had_bridge = true;
 
				} else {
 
					if ((!had_tunnel || GetTunnelDirection(tile) == DIAGDIR_SE || GetTunnelDirection(tile) == DIAGDIR_SW)) {
 
					if ((!had_tunnel || GetTunnelBridgeDirection(tile) == DIAGDIR_SE || GetTunnelBridgeDirection(tile) == DIAGDIR_SW)) {
 
						cost.AddCost(ret);
 
					}
 
					had_tunnel = true;
 
				}
 
			} else {
 
				cost.AddCost(ret);
src/road_map.cpp
Show inline comments
 
@@ -9,12 +9,13 @@
 
#include "landscape.h"
 
#include "road_map.h"
 
#include "station.h"
 
#include "tunnel_map.h"
 
#include "station_map.h"
 
#include "depot.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
 
{
 
	if (!HasBit(GetRoadTypes(tile), rt)) return ROAD_NONE;
 

	
 
@@ -31,17 +32,17 @@ RoadBits GetAnyRoadBits(TileIndex tile, 
 
			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 (IsTunnel(tile)) {
 
				if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
 
				return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile)));
 
				if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
 
				return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
 
			} else {
 
				if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
 
				return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(tile)));
 
				if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
 
				return DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
 
			}
 

	
 
		default: return ROAD_NONE;
 
	}
 
}
 

	
src/roadveh_cmd.cpp
Show inline comments
 
@@ -34,12 +34,14 @@
 
#include "newgrf_engine.h"
 
#include "newgrf_text.h"
 
#include "newgrf_sound.h"
 
#include "yapf/yapf.h"
 
#include "date.h"
 
#include "cargotype.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
static const uint16 _roadveh_images[63] = {
 
	0xCD4, 0xCDC, 0xCE4, 0xCEC, 0xCF4, 0xCFC, 0xD0C, 0xD14,
 
	0xD24, 0xD1C, 0xD2C, 0xD04, 0xD1C, 0xD24, 0xD6C, 0xD74,
 
	0xD7C, 0xC14, 0xC1C, 0xC24, 0xC2C, 0xC34, 0xC3C, 0xC4C,
 
	0xC54, 0xC64, 0xC5C, 0xC6C, 0xC44, 0xC5C, 0xC64, 0xCAC,
 
@@ -546,14 +548,14 @@ CommandCost CmdTurnRoadVeh(TileIndex til
 
			v->cur_speed < 5) {
 
		return CMD_ERROR;
 
	}
 

	
 
	if (IsTileType(v->tile, MP_ROAD) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR;
 

	
 
	if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelDirection(v->tile)) return CMD_ERROR;
 
	if (IsBridgeTile(v->tile) && DirToDiagDir(v->direction) == GetBridgeRampDirection(v->tile)) return CMD_ERROR;
 
	if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
 
	if (IsBridgeTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelBridgeDirection(v->tile)) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) v->u.road.reverse_ctr = 180;
 

	
 
	return CommandCost();
 
}
 

	
 
@@ -1403,15 +1405,15 @@ static Trackdir FollowPreviousRoadVehicl
 
	Trackdir dir;
 

	
 
	if (prev_state == RVSB_WORMHOLE || prev_state == RVSB_IN_DEPOT) {
 
		DiagDirection diag_dir = INVALID_DIAGDIR;
 

	
 
		if (IsTunnelTile(tile)) {
 
			diag_dir = GetTunnelDirection(tile);
 
			diag_dir = GetTunnelBridgeDirection(tile);
 
		} else if (IsBridgeTile(tile)) {
 
			diag_dir = GetBridgeRampDirection(tile);
 
			diag_dir = GetTunnelBridgeDirection(tile);
 
		} else if (IsTileType(tile, MP_ROAD) && GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
 
			diag_dir = ReverseDiagDir(GetRoadDepotDirection(tile));
 
		}
 

	
 
		if (diag_dir == INVALID_DIAGDIR) return INVALID_TRACKDIR;
 
		dir = DiagdirToDiagTrackdir(diag_dir);
src/smallmap_gui.cpp
Show inline comments
 
@@ -25,12 +25,14 @@
 
#include "player.h"
 
#include "vehicle.h"
 
#include "town.h"
 
#include "sound.h"
 
#include "variables.h"
 
#include "blitter/factory.hpp"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
static const Widget _smallmap_widgets[] = {
 
{  WWT_CLOSEBOX,   RESIZE_NONE,    13,     0,    10,     0,    13, STR_00C5,                STR_018B_CLOSE_WINDOW},
 
{   WWT_CAPTION,  RESIZE_RIGHT,    13,    11,   337,     0,    13, STR_00B0_MAP,            STR_018C_WINDOW_TITLE_DRAG_THIS},
 
{ WWT_STICKYBOX,     RESIZE_LR,    13,   338,   349,     0,    13, 0x0,                     STR_STICKY_BUTTON},
 
{     WWT_PANEL,     RESIZE_RB,    13,     0,   349,    14,   157, 0x0,                     STR_NULL},
 
@@ -337,15 +339,15 @@ static inline TileType GetEffectiveTileT
 
	TileType t = GetTileType(tile);
 

	
 
	if (t == MP_TUNNELBRIDGE) {
 
		TransportType tt;
 

	
 
		if (IsTunnel(tile)) {
 
			tt = GetTunnelTransportType(tile);
 
			tt = GetTunnelBridgeTransportType(tile);
 
		} else {
 
			tt = GetBridgeTransportType(tile);
 
			tt = GetTunnelBridgeTransportType(tile);
 
		}
 
		switch (tt) {
 
			case TRANSPORT_RAIL: t = MP_RAILWAY; break;
 
			case TRANSPORT_ROAD: t = MP_ROAD;    break;
 
			default:             t = MP_WATER;   break;
 
		}
src/town_cmd.cpp
Show inline comments
 
@@ -41,12 +41,14 @@
 
#include "newgrf_commons.h"
 
#include "newgrf_townname.h"
 
#include "misc/autoptr.hpp"
 
#include "autoslope.h"
 
#include "waypoint.h"
 
#include "transparency.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
/* Initialize the town-pool */
 
DEFINE_OLD_POOL_GENERIC(Town, Town)
 

	
 
Town::Town(TileIndex tile)
 
{
 
@@ -1059,15 +1061,15 @@ static void GrowTownInTile(TileIndex *ti
 
		}
 
	} else {
 
		bool allow_house = false; // Value which decides if we want to construct a house
 

	
 
		/* Reached a tunnel/bridge? Then continue at the other side of it. */
 
		if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
			if (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) {
 
			if (IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
 
				*tile_ptr = GetOtherTunnelEnd(tile);
 
			} else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_ROAD) {
 
			} else if (IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD) {
 
				*tile_ptr = GetOtherBridgeEnd(tile);
 
			}
 
			return;
 
		}
 

	
 
		/* Possibly extend the road in a direction.
src/train_cmd.cpp
Show inline comments
 
@@ -39,12 +39,14 @@
 
#include "direction.h"
 
#include "yapf/yapf.h"
 
#include "date.h"
 
#include "cargotype.h"
 
#include "group.h"
 
#include "table/sprites.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
static bool TrainCheckIfLineEnds(Vehicle *v);
 
static void TrainController(Vehicle *v, bool update_image);
 

	
 
static const byte _vehicle_initial_x_fract[4] = {10, 8, 4,  8};
 
static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10};
 
@@ -3054,13 +3056,13 @@ static void DeleteLastWagon(Vehicle *v)
 

	
 
	if (v->u.rail.track == TRACK_BIT_WORMHOLE) { // inside a tunnel / bridge
 
		TileIndex endtile = IsTunnel(v->tile) ? GetOtherTunnelEnd(v->tile) : GetOtherBridgeEnd(v->tile);
 

	
 
		if (GetVehicleTunnelBridge(v->tile, endtile) != NULL) return; // tunnel / bridge is busy
 

	
 
		DiagDirection dir = IsTunnel(v->tile) ? GetTunnelDirection(v->tile) : GetBridgeRampDirection(v->tile);
 
		DiagDirection dir = IsTunnel(v->tile) ? GetTunnelBridgeDirection(v->tile) : GetTunnelBridgeDirection(v->tile);
 

	
 
		/* v->direction is "random", so it cannot be used to determine the direction of the track */
 
		UpdateSignalsOnSegment(v->tile, dir);
 
		UpdateSignalsOnSegment(endtile, ReverseDiagDir(dir));
 
	}
 
}
 
@@ -3171,13 +3173,13 @@ static bool TrainCheckIfLineEnds(Vehicle
 
	if (v->u.rail.track == TRACK_BIT_WORMHOLE) return true; // exit if inside a tunnel
 
	if (v->u.rail.track == TRACK_BIT_DEPOT) return true; // exit if inside a depot
 

	
 
	TileIndex tile = v->tile;
 

	
 
	if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		DiagDirection dir = IsTunnel(tile) ? GetTunnelDirection(tile) : GetBridgeRampDirection(tile);
 
		DiagDirection dir = IsTunnel(tile) ? GetTunnelBridgeDirection(tile) : GetTunnelBridgeDirection(tile);
 
		if (DiagDirToDir(dir) == v->direction) return true;
 
	}
 

	
 
	// depot?
 
	/* XXX -- When enabled, this makes it possible to crash trains of others
 
	     (by building a depot right against a station) */
src/tunnel_map.cpp
Show inline comments
 
@@ -3,31 +3,33 @@
 
/** @file tunnel_map.cpp */
 

	
 
#include "stdafx.h"
 
#include "openttd.h"
 
#include "tile.h"
 
#include "tunnel_map.h"
 
#include "tunnelbridge_map.h"
 

	
 

	
 
/**
 
 * Gets the other end of the tunnel. Where a vehicle would reappear when it
 
 * enters at the given tile.
 
 * @param tile the tile to search from.
 
 * @return the tile of the other end of the tunnel.
 
 */
 
TileIndex GetOtherTunnelEnd(TileIndex tile)
 
{
 
	DiagDirection dir = GetTunnelDirection(tile);
 
	DiagDirection dir = GetTunnelBridgeDirection(tile);
 
	TileIndexDiff delta = TileOffsByDiagDir(dir);
 
	uint z = GetTileZ(tile);
 

	
 
	dir = ReverseDiagDir(dir);
 
	do {
 
		tile += delta;
 
	} while (
 
		!IsTunnelTile(tile) ||
 
		GetTunnelDirection(tile) != dir ||
 
		GetTunnelBridgeDirection(tile) != dir ||
 
		GetTileZ(tile) != z
 
	);
 

	
 
	return tile;
 
}
 

	
 
@@ -49,13 +51,13 @@ bool IsTunnelInWayDir(TileIndex tile, ui
 
		height = GetTileZ(tile);
 
	} while (z < height);
 

	
 
	return
 
		z == height &&
 
		IsTunnelTile(tile) &&
 
		GetTunnelDirection(tile) == dir;
 
		GetTunnelBridgeDirection(tile) == dir;
 
}
 

	
 
/**
 
 * Is there a tunnel in the way in any direction?
 
 * @param tile the tile to search from.
 
 * @param z the 'z' to search on.
src/tunnel_map.h
Show inline comments
 
@@ -8,91 +8,39 @@
 
#include "direction.h"
 
#include "macros.h"
 
#include "map.h"
 
#include "rail.h"
 
#include "road.h"
 

	
 

	
 
/**
 
 * Is this a tunnel (entrance)?
 
 * @param t the tile that might be a tunnel
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return true if and only if this tile is a tunnel (entrance)
 
 */
 
static inline bool IsTunnel(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return !HasBit(_m[t].m5, 7);
 
}
 

	
 

	
 
/**
 
 * Is this a tunnel (entrance)?
 
 * @param t the tile that might be a tunnel
 
 * @return true if and only if this tile is a tunnel (entrance)
 
 */
 
static inline bool IsTunnelTile(TileIndex t)
 
{
 
	return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
 
}
 

	
 
/**
 
 * Gets the direction facing out of the tunnel
 
 * @param t the tile to get the tunnel facing direction of
 
 * @pre IsTunnelTile(t)
 
 * @return the direction the tunnel is facing
 
 */
 
static inline DiagDirection GetTunnelDirection(TileIndex t)
 
{
 
	assert(IsTunnelTile(t));
 
	return (DiagDirection)GB(_m[t].m5, 0, 2);
 
}
 

	
 
/**
 
 * Gets the transport type of the tunnel (road or rail)
 
 * @param t the tunnel entrance tile to get the type of
 
 * @pre IsTunnelTile(t)
 
 * @return the transport type in the tunnel
 
 */
 
static inline TransportType GetTunnelTransportType(TileIndex t)
 
{
 
	assert(IsTunnelTile(t));
 
	return (TransportType)GB(_m[t].m5, 2, 2);
 
}
 

	
 
/**
 
 * Is this tunnel entrance in a snowy or desert area?
 
 * @param t the tunnel entrance tile
 
 * @pre IsTunnelTile(t)
 
 * @return true if and only if the tunnel entrance is in a snowy/desert area
 
 */
 
static inline bool HasTunnelSnowOrDesert(TileIndex t)
 
{
 
	assert(IsTunnelTile(t));
 
	return HasBit(_m[t].m4, 7);
 
}
 

	
 
/**
 
 * Places this tunnel entrance in a snowy or desert area,
 
 * or takes it out of there.
 
 * @param t the tunnel entrance tile
 
 * @param snow_or_desert is the entrance in snow or desert (true), when
 
 *                       not in snow and not in desert false
 
 * @pre IsTunnelTile(t)
 
 */
 
static inline void SetTunnelSnowOrDesert(TileIndex t, bool snow_or_desert)
 
{
 
	assert(IsTunnelTile(t));
 
	SB(_m[t].m4, 7, 1, snow_or_desert);
 
}
 

	
 

	
 
TileIndex GetOtherTunnelEnd(TileIndex);
 
bool IsTunnelInWay(TileIndex, uint z);
 
bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
 

	
 

	
 
/**
 
 * Makes a road tunnel entrance
 
 * @param t the entrance of the tunnel
 
 * @param o the owner of the entrance
 
 * @param d the direction facing out of the tunnel
 
 * @param r the road type used in the tunnel
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -31,14 +31,15 @@
 
#include "water_map.h"
 
#include "yapf/yapf.h"
 
#include "date.h"
 
#include "newgrf_sound.h"
 
#include "autoslope.h"
 
#include "transparency.h"
 
#include "tunnelbridge_map.h"
 
#include "table/bridge_land.h"
 

	
 
#include "table/bridge_land.h"
 

	
 
const Bridge orig_bridge[] = {
 
/*
 
	     year of availablity
 
	     |  minimum length
 
	     |  |   maximum length
 
@@ -263,13 +264,13 @@ CommandCost CmdBuildBridge(TileIndex end
 
	                   && _patches.build_on_slopes);
 

	
 
	TransportType transport_type = railtype == INVALID_RAILTYPE ? TRANSPORT_ROAD : TRANSPORT_RAIL;
 

	
 
	if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) &&
 
			GetOtherBridgeEnd(tile_start) == tile_end &&
 
			GetBridgeTransportType(tile_start) == transport_type) {
 
			GetTunnelBridgeTransportType(tile_start) == transport_type) {
 
		/* Replace a current bridge. */
 

	
 
		/* If this is a railway bridge, make sure the railtypes match. */
 
		if (transport_type == TRANSPORT_RAIL && GetRailType(tile_start) != railtype) {
 
			return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
 
		}
 
@@ -388,13 +389,13 @@ CommandCost CmdBuildBridge(TileIndex end
 
				if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) goto not_valid_below;
 
				break;
 

	
 
			case MP_TUNNELBRIDGE:
 
				if (IsTunnel(tile)) break;
 
				if (replace_bridge) break;
 
				if (direction == DiagDirToAxis(GetBridgeRampDirection(tile))) goto not_valid_below;
 
				if (direction == DiagDirToAxis(GetTunnelBridgeDirection(tile))) goto not_valid_below;
 
				if (z_start < GetBridgeHeight(tile)) goto not_valid_below;
 
				break;
 

	
 
			case MP_UNMOVABLE:
 
				if (!IsOwnedLand(tile)) goto not_valid_below;
 
				break;
 
@@ -599,13 +600,13 @@ static CommandCost DoClearTunnel(TileInd
 
		}
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		/* We first need to request the direction before calling DoClearSquare
 
		 *  else the direction is always 0.. dah!! ;) */
 
		DiagDirection dir = GetTunnelDirection(tile);
 
		DiagDirection dir = GetTunnelBridgeDirection(tile);
 
		Track track;
 

	
 
		/* Adjust the town's player rating. Do this before removing the tile owner info. */
 
		if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
 
			ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
 

	
 
@@ -633,13 +634,13 @@ static CommandCost DoClearBridge(TileInd
 
	if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR;
 

	
 
	endtile = GetOtherBridgeEnd(tile);
 

	
 
	if (GetVehicleTunnelBridge(tile, endtile) != NULL) return CMD_ERROR;
 

	
 
	direction = GetBridgeRampDirection(tile);
 
	direction = GetTunnelBridgeDirection(tile);
 
	delta = TileOffsByDiagDir(direction);
 

	
 
	if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
 
		t = ClosestTownFromTile(tile, (uint)-1); // town penalty rating
 

	
 
		/* Check if you are allowed to remove the bridge owned by a town
 
@@ -698,13 +699,13 @@ static CommandCost ClearTile_TunnelBridg
 
 * @param exec        Switches between test and execute mode
 
 * @return            The cost and state of the operation
 
 * @retval CMD_ERROR  An error occured during the operation.
 
 */
 
CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
 
{
 
	if (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_RAIL) {
 
	if (IsTunnel(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
 
		TileIndex endtile = GetOtherTunnelEnd(tile);
 

	
 
		/* If not coverting rail <-> el. rail, any vehicle cannot be in tunnel */
 
		if (!IsCompatibleRail(GetRailType(tile), totype) &&
 
				GetVehicleTunnelBridge(tile, endtile) != NULL) {
 
			return CMD_ERROR;
 
@@ -713,23 +714,23 @@ CommandCost DoConvertTunnelBridgeRail(Ti
 
		if (exec) {
 
			SetRailType(tile, totype);
 
			SetRailType(endtile, totype);
 
			MarkTileDirtyByTile(tile);
 
			MarkTileDirtyByTile(endtile);
 

	
 
			Track track = AxisToTrack(DiagDirToAxis(GetTunnelDirection(tile)));
 
			Track track = AxisToTrack(DiagDirToAxis(GetTunnelBridgeDirection(tile)));
 

	
 
			YapfNotifyTrackLayoutChange(tile, track);
 
			YapfNotifyTrackLayoutChange(endtile, track);
 

	
 
			VehicleFromPos(tile, NULL, &UpdateTrainPowerProc);
 
			VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc);
 
		}
 

	
 
		return CommandCost((DistanceManhattan(tile, endtile) + 1) * RailConvertCost(GetRailType(tile), totype));
 
	} else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
 
	} else if (IsBridge(tile) && GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) {
 
		TileIndex endtile = GetOtherBridgeEnd(tile);
 

	
 
		if (!IsCompatibleRail(GetRailType(tile), totype) &&
 
				GetVehicleTunnelBridge(tile, endtile) != NULL) {
 
			return CMD_ERROR;
 
		}
 
@@ -737,14 +738,14 @@ CommandCost DoConvertTunnelBridgeRail(Ti
 
		if (exec) {
 
			SetRailType(tile, totype);
 
			SetRailType(endtile, totype);
 
			MarkTileDirtyByTile(tile);
 
			MarkTileDirtyByTile(endtile);
 

	
 
			Track track = AxisToTrack(DiagDirToAxis(GetBridgeRampDirection(tile)));
 
			TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
 
			Track track = AxisToTrack(DiagDirToAxis(GetTunnelBridgeDirection(tile)));
 
			TileIndexDiff delta = TileOffsByDiagDir(GetTunnelBridgeDirection(tile));
 

	
 
			YapfNotifyTrackLayoutChange(tile, track);
 
			YapfNotifyTrackLayoutChange(endtile, track);
 

	
 
			VehicleFromPos(tile, NULL, &UpdateTrainPowerProc);
 
			VehicleFromPos(endtile, NULL, &UpdateTrainPowerProc);
 
@@ -891,28 +892,28 @@ static void DrawTile_TunnelBridge(TileIn
 
			 * w  h  bb_x bb_y| x   y   w   h |bb_x bb_y w h */
 
			{  1,  0, -15, -14,  0, 15, 16,  1, 0, 1, 16, 15 }, // NE
 
			{  0,  1, -14, -15, 15,  0,  1, 16, 1, 0, 15, 16 }, // SE
 
			{  1,  0, -15, -14,  0, 15, 16,  1, 0, 1, 16, 15 }, // SW
 
			{  0,  1, -14, -15, 15,  0,  1, 16, 1, 0, 15, 16 }, // NW
 
		};
 
		const int *BB_data = _tunnel_BB[GetTunnelDirection(ti->tile)];
 
		const int *BB_data = _tunnel_BB[GetTunnelBridgeDirection(ti->tile)];
 

	
 
		bool catenary = false;
 

	
 
		if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
 
		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
 
			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
 
		} else {
 
			image = SPR_TUNNEL_ENTRY_REAR_ROAD;
 
		}
 

	
 
		if (HasTunnelSnowOrDesert(ti->tile)) image += 32;
 
		if (HasTunnelBridgeSnowOrDesert(ti->tile)) image += 32;
 

	
 
		image += GetTunnelDirection(ti->tile) * 2;
 
		image += GetTunnelBridgeDirection(ti->tile) * 2;
 
		DrawGroundSprite(image, PAL_NONE);
 
		if (GetTunnelTransportType(ti->tile) == TRANSPORT_ROAD) {
 
			DiagDirection dir = GetTunnelDirection(ti->tile);
 
		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
 
			DiagDirection dir = GetTunnelBridgeDirection(ti->tile);
 
			RoadTypes rts = GetRoadTypes(ti->tile);
 

	
 
			if (HasBit(rts, ROADTYPE_TRAM)) {
 
				static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, {  5, 76, 77,  4 } };
 

	
 
				DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE);
 
@@ -938,28 +939,28 @@ static void DrawTile_TunnelBridge(TileIn
 
		AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, ti->x + BB_data[4], ti->y + BB_data[5], BB_data[6], BB_data[7], TILE_HEIGHT, ti->z);
 

	
 
		DrawBridgeMiddle(ti);
 
	} else if (IsBridge(ti->tile)) { // XXX is this necessary?
 
		const PalSpriteID *psid;
 
		int base_offset;
 
		bool ice = HasBridgeSnowOrDesert(ti->tile);
 
		bool ice = HasTunnelBridgeSnowOrDesert(ti->tile);
 

	
 
		if (GetBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
 
		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
 
			base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
 
			assert(base_offset != 8); // This one is used for roads
 
		} else {
 
			base_offset = 8;
 
		}
 

	
 
		/* as the lower 3 bits are used for other stuff, make sure they are clear */
 
		assert( (base_offset & 0x07) == 0x00);
 

	
 
		DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetBridgeRampDirection(ti->tile))));
 
		DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetTunnelBridgeDirection(ti->tile))));
 

	
 
		/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
 
		base_offset += (6 - GetBridgeRampDirection(ti->tile)) % 4;
 
		base_offset += (6 - GetTunnelBridgeDirection(ti->tile)) % 4;
 

	
 
		if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
 

	
 
		/* Table number 6 always refers to the bridge heads for any bridge type */
 
		psid = &GetBridgeSpriteTable(GetBridgeType(ti->tile), 6)[base_offset];
 

	
 
@@ -969,26 +970,26 @@ static void DrawTile_TunnelBridge(TileIn
 
			DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE);
 
		}
 

	
 
		/* draw ramp */
 

	
 
		/* Draw Trambits as SpriteCombine */
 
		if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) StartSpriteCombine();
 
		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) StartSpriteCombine();
 

	
 
		/* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on
 
		 * it doesn't disappear behind it
 
		 */
 
		AddSortableSpriteToDraw(
 
			psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, IsTransparencySet(TO_BRIDGES)
 
		);
 

	
 
		if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
 
		if (GetTunnelBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
 
			RoadTypes rts = GetRoadTypes(ti->tile);
 

	
 
			if (HasBit(rts, ROADTYPE_TRAM)) {
 
				uint offset = GetBridgeRampDirection(ti->tile);
 
				uint offset = GetTunnelBridgeDirection(ti->tile);
 
				uint z = ti->z;
 
				if (ti->tileh != SLOPE_FLAT) {
 
					offset = (offset + 1) & 1;
 
					z += TILE_HEIGHT;
 
				} else {
 
					offset += 2;
 
@@ -1081,13 +1082,13 @@ void DrawBridgeMiddle(const TileInfo* ti
 
	piece = CalcBridgePiece(
 
		DistanceManhattan(ti->tile, rampnorth),
 
		DistanceManhattan(ti->tile, rampsouth)
 
	);
 
	type = GetBridgeType(rampsouth);
 

	
 
	if (GetBridgeTransportType(rampsouth) == TRANSPORT_RAIL) {
 
	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_RAIL) {
 
		base_offset = GetRailTypeInfo(GetRailType(rampsouth))->bridge_offset;
 
	} else {
 
		base_offset = 8;
 
	}
 

	
 
	psid = base_offset + GetBridgeSpriteTable(type, piece);
 
@@ -1099,24 +1100,24 @@ void DrawBridgeMiddle(const TileInfo* ti
 
	z = bridge_z - BRIDGE_Z_START;
 

	
 
	/* Add a bounding box, that separates the bridge from things below it. */
 
	AddSortableSpriteToDraw(SPR_EMPTY_BOUNDING_BOX, PAL_NONE, x, y, 16, 16, 1, bridge_z - TILE_HEIGHT + BB_Z_SEPARATOR);
 

	
 
	/* Draw Trambits as SpriteCombine */
 
	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) StartSpriteCombine();
 
	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) StartSpriteCombine();
 

	
 
	/* Draw floor and far part of bridge*/
 
	if (axis == AXIS_X) {
 
		AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
 
	} else {
 
		AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 0, 0, BRIDGE_Z_START);
 
	}
 

	
 
	psid++;
 

	
 
	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
 
	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
 
		RoadTypes rts = GetRoadTypes(rampsouth);
 

	
 
		if (HasBit(rts, ROADTYPE_TRAM)) {
 
			/* DrawBridgeTramBits() calls EndSpriteCombine() and StartSpriteCombine() */
 
			DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HasBit(rts, ROADTYPE_ROAD));
 
		} else {
 
@@ -1134,13 +1135,13 @@ void DrawBridgeMiddle(const TileInfo* ti
 
	} else {
 
		x += 12;
 
		if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 4, 16, 0x28, z, IsTransparencySet(TO_BRIDGES), 3, 0, BRIDGE_Z_START);
 
	}
 

	
 
	/* Draw TramFront as SpriteCombine */
 
	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) EndSpriteCombine();
 
	if (GetTunnelBridgeTransportType(rampsouth) == TRANSPORT_ROAD) EndSpriteCombine();
 

	
 
	psid++;
 
	if (ti->z + 5 == z) {
 
		/* draw poles below for small bridges */
 
		if (psid->sprite != 0) {
 
			SpriteID image = psid->sprite;
 
@@ -1165,18 +1166,18 @@ static uint GetSlopeZ_TunnelBridge(TileI
 
	Slope tileh = GetTileSlope(tile, &z);
 

	
 
	x &= 0xF;
 
	y &= 0xF;
 

	
 
	if (IsTunnel(tile)) {
 
		uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x);
 
		uint pos = (DiagDirToAxis(GetTunnelBridgeDirection(tile)) == AXIS_X ? y : x);
 

	
 
		/* In the tunnel entrance? */
 
		if (5 <= pos && pos <= 10) return z;
 
	} else {
 
		DiagDirection dir = GetBridgeRampDirection(tile);
 
		DiagDirection dir = GetTunnelBridgeDirection(tile);
 
		uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
 

	
 
		z += ApplyFoundationToSlope(GetBridgeFoundation(tileh, DiagDirToAxis(dir)), &tileh);
 

	
 
		/* On the bridge ramp? */
 
		if (5 <= pos && pos <= 10) {
 
@@ -1197,13 +1198,13 @@ static uint GetSlopeZ_TunnelBridge(TileI
 

	
 
	return z + GetPartialZ(x, y, tileh);
 
}
 

	
 
static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh)
 
{
 
	return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
 
	return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(tile)));
 
}
 

	
 

	
 
static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac)
 
{
 
	/* not used */
 
@@ -1241,47 +1242,47 @@ static const StringID _bridge_tile_str[(
 
	0, 0, 0,
 
};
 

	
 
static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td)
 
{
 
	if (IsTunnel(tile)) {
 
		td->str = (GetTunnelTransportType(tile) == TRANSPORT_RAIL) ?
 
		td->str = (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ?
 
			STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL;
 
	} else {
 
		td->str = _bridge_tile_str[GetBridgeTransportType(tile) << 4 | GetBridgeType(tile)];
 
		td->str = _bridge_tile_str[GetTunnelBridgeTransportType(tile) << 4 | GetBridgeType(tile)];
 
	}
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 

	
 
static void AnimateTile_TunnelBridge(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
static void TileLoop_TunnelBridge(TileIndex tile)
 
{
 
	bool snow_or_desert = IsTunnelTile(tile) ? HasTunnelSnowOrDesert(tile) : HasBridgeSnowOrDesert(tile);
 
	bool snow_or_desert = IsTunnelTile(tile) ? HasTunnelBridgeSnowOrDesert(tile) : HasTunnelBridgeSnowOrDesert(tile);
 
	switch (_opt.landscape) {
 
		case LT_ARCTIC:
 
			if (snow_or_desert != (GetTileZ(tile) > GetSnowLine())) {
 
				if (IsTunnelTile(tile)) {
 
					SetTunnelSnowOrDesert(tile, !snow_or_desert);
 
					SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
 
				} else {
 
					SetBridgeSnowOrDesert(tile, !snow_or_desert);
 
					SetTunnelBridgeSnowOrDesert(tile, !snow_or_desert);
 
				}
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 

	
 
		case LT_TROPIC:
 
			if (GetTropicZone(tile) == TROPICZONE_DESERT && !snow_or_desert) {
 
				if (IsTunnelTile(tile)) {
 
					SetTunnelSnowOrDesert(tile, true);
 
					SetTunnelBridgeSnowOrDesert(tile, true);
 
				} else {
 
					SetBridgeSnowOrDesert(tile, true);
 
					SetTunnelBridgeSnowOrDesert(tile, true);
 
				}
 
				MarkTileDirtyByTile(tile);
 
			}
 
			break;
 
	}
 
}
 
@@ -1292,19 +1293,19 @@ static void ClickTile_TunnelBridge(TileI
 
}
 

	
 

	
 
static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode)
 
{
 
	if (IsTunnel(tile)) {
 
		if (GetTunnelTransportType(tile) != mode) return 0;
 
		if (GetTunnelTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
 
		return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(tile))) * 0x101;
 
		if (GetTunnelBridgeTransportType(tile) != mode) return 0;
 
		if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
 
		return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
 
	} else {
 
		if (GetBridgeTransportType(tile) != mode) return 0;
 
		if (GetBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
 
		return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(tile))) * 0x101;
 
		if (GetTunnelBridgeTransportType(tile) != mode) return 0;
 
		if (GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
 
		return AxisToTrackBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) * 0x101;
 
	}
 
}
 

	
 
static void ChangeTileOwner_TunnelBridge(TileIndex tile, PlayerID old_player, PlayerID new_player)
 
{
 
	if (!IsTileOwner(tile, old_player)) return;
 
@@ -1314,13 +1315,13 @@ static void ChangeTileOwner_TunnelBridge
 
	} else {
 
		if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
 
			/* When clearing the bridge/tunnel failed there are still vehicles on/in
 
			 * the bridge/tunnel. As all *our* vehicles are already removed, they
 
			 * must be of another owner. Therefor this must be a road bridge/tunnel.
 
			 * In that case we can safely reassign the ownership to OWNER_NONE. */
 
			assert((IsTunnel(tile) ? GetTunnelTransportType(tile) : GetBridgeTransportType(tile)) == TRANSPORT_ROAD);
 
			assert((IsTunnel(tile) ? GetTunnelBridgeTransportType(tile) : GetTunnelBridgeTransportType(tile)) == TRANSPORT_ROAD);
 
			SetTileOwner(tile, OWNER_NONE);
 
		}
 
	}
 
}
 

	
 

	
 
@@ -1351,13 +1352,13 @@ static uint32 VehicleEnter_TunnelBridge(
 
		DiagDirection dir;
 
		DiagDirection vdir;
 

	
 
		if (v->type == VEH_TRAIN) {
 
			fc = (x & 0xF) + (y << 4);
 

	
 
			dir = GetTunnelDirection(tile);
 
			dir = GetTunnelBridgeDirection(tile);
 
			vdir = DirToDiagDir(v->direction);
 

	
 
			if (v->u.rail.track != TRACK_BIT_WORMHOLE && dir == vdir) {
 
				if (IsFrontEngine(v) && fc == _tunnel_fractcoord_1[dir]) {
 
					if (!PlayVehicleSound(v, VSE_TUNNEL) && RailVehInfo(v->engine_type)->engclass == 0) {
 
						SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v);
 
@@ -1379,13 +1380,13 @@ static uint32 VehicleEnter_TunnelBridge(
 
				assert(v->u.rail.track);
 
				v->vehstatus &= ~VS_HIDDEN;
 
				return VETSB_ENTERED_WORMHOLE;
 
			}
 
		} else if (v->type == VEH_ROAD) {
 
			fc = (x & 0xF) + (y << 4);
 
			dir = GetTunnelDirection(tile);
 
			dir = GetTunnelBridgeDirection(tile);
 
			vdir = DirToDiagDir(v->direction);
 

	
 
			/* Enter tunnel? */
 
			if (v->u.road.state != RVSB_WORMHOLE && dir == vdir) {
 
				if (fc == _tunnel_fractcoord_4[dir] ||
 
						fc == _tunnel_fractcoord_5[dir]) {
 
@@ -1419,13 +1420,13 @@ static uint32 VehicleEnter_TunnelBridge(
 
			uint16 spd = _bridge[GetBridgeType(tile)].speed;
 

	
 
			if (v->type == VEH_ROAD) spd *= 2;
 
			if (v->cur_speed > spd) v->cur_speed = spd;
 
		}
 

	
 
		dir = GetBridgeRampDirection(tile);
 
		dir = GetTunnelBridgeDirection(tile);
 
		if (DirToDiagDir(v->direction) == dir) {
 
			switch (dir) {
 
				default: NOT_REACHED();
 
				case DIAGDIR_NE: if ((x & 0xF) != 0)             return VETSB_CONTINUE; break;
 
				case DIAGDIR_SE: if ((y & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break;
 
				case DIAGDIR_SW: if ((x & 0xF) != TILE_SIZE - 1) return VETSB_CONTINUE; break;
 
@@ -1459,13 +1460,13 @@ static uint32 VehicleEnter_TunnelBridge(
 
	return VETSB_CONTINUE;
 
}
 

	
 
static CommandCost TerraformTile_TunnelBridge(TileIndex tile, uint32 flags, uint z_new, Slope tileh_new)
 
{
 
	if (_patches.build_on_slopes && AutoslopeEnabled() && IsBridge(tile)) {
 
		DiagDirection direction = GetBridgeRampDirection(tile);
 
		DiagDirection direction = GetTunnelBridgeDirection(tile);
 
		Axis axis = DiagDirToAxis(direction);
 
		CommandCost res;
 

	
 
		/* Check if new slope is valid for bridges in general (so we can savely call GetBridgeFoundation()) */
 
		if ((direction == DIAGDIR_NW) || (direction == DIAGDIR_NE)) {
 
			res = CheckBridgeSlopeSouth(axis, tileh_new);
src/tunnelbridge_map.h
Show inline comments
 
new file 100644
 
/* $Id$ */
 

	
 
/** @file tunnelbridge_map.h Functions that have tunnels and bridges in common */
 

	
 
#ifndef TUNNELBRIDGE_MAP_H
 
#define TUNNELBRIDGE_MAP_H
 

	
 
#include "direction.h"            /* DiagDirection */
 
#include "core/bitmath_func.hpp"  /* GB, HasBit, SB */
 
#include "map.h"                  /* Tile, TileIndex */
 
#include "tile.h"                 /* TileType, IsTileType */
 
#include "openttd.h"              /* TransportType */
 

	
 

	
 
/**
 
 * Tunnel: Get the direction facing out of the tunnel
 
 * Bridge: Get the direction pointing onto the bridge
 
 * @param t The tile to analyze
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return the above mentionned direction
 
 */
 
static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return (DiagDirection)GB(_m[t].m5, 0, 2);
 
}
 

	
 
/**
 
 * Tunnel: Get the transport type of the tunnel (road or rail)
 
 * Bridge: Get the transport type of the bridge's ramp
 
 * @param t The tile to analyze
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return the transport type in the tunnel/bridge
 
 */
 
static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return (TransportType)GB(_m[t].m5, 2, 2);
 
}
 

	
 
/**
 
 * Tunnel: Is this tunnel entrance in a snowy or desert area?
 
 * Bridge: Does the bridge ramp lie in a snow or desert area?
 
 * @param t The tile to analyze
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return true if and only if the tile is in a snowy/desert area
 
 */
 
static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return HasBit(_m[t].m4, 7);
 
}
 

	
 
/**
 
 * Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there.
 
 * Bridge: Sets whether the bridge ramp lies in a snow or desert area.
 
 * @param t the tunnel entrance / bridge ramp tile
 
 * @param snow_or_desert is the entrance/ramp in snow or desert (true), when
 
 *                       not in snow and not in desert false
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 */
 
static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	SB(_m[t].m4, 7, 1, snow_or_desert);
 
}
 

	
 
#endif /* TUNNELBRIDGE_MAP_H */
src/yapf/follow_track.hpp
Show inline comments
 
@@ -75,13 +75,13 @@ protected:
 
	{
 
		m_is_station = m_is_bridge = m_is_tunnel = false;
 
		m_tiles_skipped = 0;
 

	
 
		// extra handling for tunnels in our direction
 
		if (IsTunnelTile(m_old_tile)) {
 
			DiagDirection tunnel_enterdir = GetTunnelDirection(m_old_tile);
 
			DiagDirection tunnel_enterdir = GetTunnelBridgeDirection(m_old_tile);
 
			if (tunnel_enterdir == m_exitdir) {
 
				// we are entering the tunnel
 
				FindLengthOfTunnelResult flotr = FindLengthOfTunnel(m_old_tile, m_exitdir);
 
				m_new_tile = flotr.tile;
 
				m_is_tunnel = true;
 
				m_tiles_skipped = flotr.length - 1;
 
@@ -89,13 +89,13 @@ protected:
 
			}
 
			assert(ReverseDiagDir(tunnel_enterdir) == m_exitdir);
 
		}
 

	
 
		// extra handling for bridge ramp in our direction
 
		if (IsBridgeTile(m_old_tile)) {
 
			DiagDirection bridge_enterdir = GetBridgeRampDirection(m_old_tile);
 
			DiagDirection bridge_enterdir = GetTunnelBridgeDirection(m_old_tile);
 
			if (bridge_enterdir == m_exitdir) {
 
				// we are entering the bridge ramp
 
				m_new_tile = GetOtherBridgeEnd(m_old_tile);
 
				uint32 bridge_length = GetBridgeLength(m_old_tile, m_new_tile);
 
				m_tiles_skipped = bridge_length;
 
				m_is_bridge = true;
 
@@ -205,21 +205,21 @@ protected:
 
		}
 

	
 
		// tunnel holes and bridge ramps can be entered only from proper direction
 
		if (!IsWaterTT() && IsTileType(m_new_tile, MP_TUNNELBRIDGE)) {
 
			if (IsTunnel(m_new_tile)) {
 
				if (!m_is_tunnel) {
 
					DiagDirection tunnel_enterdir = GetTunnelDirection(m_new_tile);
 
					DiagDirection tunnel_enterdir = GetTunnelBridgeDirection(m_new_tile);
 
					if (tunnel_enterdir != m_exitdir) {
 
						m_err = EC_NO_WAY;
 
						return false;
 
					}
 
				}
 
			} else if (IsBridge(m_new_tile)) {
 
				if (!m_is_bridge) {
 
					DiagDirection ramp_enderdir = GetBridgeRampDirection(m_new_tile);
 
					DiagDirection ramp_enderdir = GetTunnelBridgeDirection(m_new_tile);
 
					if (ramp_enderdir != m_exitdir) {
 
						m_err = EC_NO_WAY;
 
						return false;
 
					}
 
				}
 
			}
src/yapf/yapf.hpp
Show inline comments
 
@@ -9,12 +9,13 @@
 

	
 
#include "../vehicle.h"
 
#include "../depot.h"
 
#include "../road_map.h"
 
#include "../tunnel_map.h"
 
#include "../bridge_map.h"
 
#include "../tunnelbridge_map.h"
 
#include "../bridge.h"
 
#include "../station.h"
 
#include "../station_map.h"
 
#include "../date.h"
 
#include "../functions.h"
 
#include "../landscape.h"
src/yapf/yapf_costbase.hpp
Show inline comments
 
@@ -8,13 +8,13 @@ struct CYapfCostBase {
 

	
 
	FORCEINLINE static bool stSlopeCost(TileIndex tile, Trackdir td)
 
	{
 
		if (IsDiagonalTrackdir(td)) {
 
			if (IsBridgeTile(tile)) {
 
				// it is bridge ramp, check if we are entering the bridge
 
				if (GetBridgeRampDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty
 
				if (GetTunnelBridgeDirection(tile) != TrackdirToExitdir(td)) return false; // no, we are living it, no penalty
 
				// we are entering the bridge
 
				// if the tile slope is downwards, then bridge ramp has not upward slope
 
				uint tile_slope = GetTileSlope(tile, NULL) & 0x0F;
 
				if ((c_upwards_slopes[tile_slope] & TrackdirToTrackdirBits(ReverseTrackdir(td))) != 0) return false; // tile under ramp goes down, no penalty
 
				// tile under ramp isn't going down, so ramp must go up
 
				return true;
0 comments (0 inline, 0 general)