You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
954 B
C++
51 lines
954 B
C++
19 years ago
|
/* $Id$ */
|
||
|
|
||
|
#include "stdafx.h"
|
||
|
#include "openttd.h"
|
||
|
#include "tile.h"
|
||
|
#include "tunnel_map.h"
|
||
|
|
||
|
TileIndex GetOtherTunnelEnd(TileIndex tile)
|
||
|
{
|
||
|
DiagDirection dir = GetTunnelDirection(tile);
|
||
18 years ago
|
TileIndexDiff delta = TileOffsByDiagDir(dir);
|
||
19 years ago
|
uint z = GetTileZ(tile);
|
||
|
|
||
|
dir = ReverseDiagDir(dir);
|
||
|
do {
|
||
|
tile += delta;
|
||
|
} while (
|
||
19 years ago
|
!IsTunnelTile(tile) ||
|
||
19 years ago
|
GetTunnelDirection(tile) != dir ||
|
||
|
GetTileZ(tile) != z
|
||
|
);
|
||
|
|
||
|
return tile;
|
||
|
}
|
||
19 years ago
|
|
||
|
|
||
|
static bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir)
|
||
|
{
|
||
18 years ago
|
TileIndexDiff delta = TileOffsByDiagDir(dir);
|
||
19 years ago
|
uint height;
|
||
|
|
||
|
do {
|
||
|
tile -= delta;
|
||
|
height = GetTileZ(tile);
|
||
|
} while (z < height);
|
||
|
|
||
|
return
|
||
|
z == height &&
|
||
19 years ago
|
IsTunnelTile(tile) &&
|
||
19 years ago
|
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);
|
||
|
}
|