Files @ r5857:4b1b2f7c805d
Branch filter:

Location: cpp/openttd-patchpack/source/src/tunnel_map.cpp

miham
(svn r8431) -Update: WebTranslator2 update to 2007-01-27 19:34:37
catalan - 4 fixed by arnaullv (4)
danish - 4 fixed, 2 changed by MiR (6)
dutch - 4 fixed by habell (4)
french - 4 fixed by glx (4)
german - 4 fixed by Neonox (4)
hungarian - 4 fixed by miham (4)
korean - 4 fixed, 4 changed by Nios (4), leejaeuk5 (4)
lithuanian - 2 changed by Domas (2)
polish - 4 fixed by meush (4)
portuguese - 4 fixed by izhirahider (4)
simplified_chinese - 4 fixed by Fishingsnow (4)
slovenian - 4 fixed, 410 changed by Necrolyte (414)
ukrainian - 34 fixed, 49 changed by mad (79), znikoz (4)
/* $Id$ */

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

TileIndex GetOtherTunnelEnd(TileIndex tile)
{
	DiagDirection dir = GetTunnelDirection(tile);
	TileIndexDiff delta = TileOffsByDiagDir(dir);
	uint z = GetTileZ(tile);

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

	return tile;
}


static bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir)
{
	TileIndexDiff delta = TileOffsByDiagDir(dir);
	uint height;

	do {
		tile -= delta;
		height = GetTileZ(tile);
	} while (z < height);

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

bool IsTunnelInWay(TileIndex tile, uint z)
{
	return
		IsTunnelInWayDir(tile, z, DIAGDIR_NE) ||
		IsTunnelInWayDir(tile, z, DIAGDIR_SE) ||
		IsTunnelInWayDir(tile, z, DIAGDIR_SW) ||
		IsTunnelInWayDir(tile, z, DIAGDIR_NW);
}