mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
/* $Id$ */
|
|
|
|
/** @file bridge_map.cpp Map accessor functions for bridges. */
|
|
|
|
#include "stdafx.h"
|
|
#include "bridge_map.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) || GetTunnelBridgeDirection(tile) != dir);
|
|
|
|
return tile;
|
|
}
|
|
|
|
|
|
TileIndex GetNorthernBridgeEnd(TileIndex t)
|
|
{
|
|
return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t))));
|
|
}
|
|
|
|
|
|
TileIndex GetSouthernBridgeEnd(TileIndex t)
|
|
{
|
|
return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t)));
|
|
}
|
|
|
|
|
|
TileIndex GetOtherBridgeEnd(TileIndex tile)
|
|
{
|
|
assert(IsBridgeTile(tile));
|
|
return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
|
|
}
|
|
|
|
uint GetBridgeHeight(TileIndex t)
|
|
{
|
|
uint h;
|
|
Slope tileh = GetTileSlope(t, &h);
|
|
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
|
|
|
|
/* one height level extra for the ramp */
|
|
return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh);
|
|
}
|