2006-03-15 16:44:50 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "openttd.h"
|
|
|
|
#include "bridge_map.h"
|
2006-06-02 13:05:41 +00:00
|
|
|
#include "variables.h"
|
2006-03-15 16:44:50 +00:00
|
|
|
|
|
|
|
|
2006-03-16 05:28:15 +00:00
|
|
|
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
|
|
|
|
{
|
|
|
|
TileIndexDiff delta = TileOffsByDir(dir);
|
|
|
|
|
2006-06-02 13:05:41 +00:00
|
|
|
do { tile += delta; } while (IsBridgeAbove(tile) && IsBridgeOfAxis(tile, DiagDirToAxis(dir)));
|
2006-03-16 05:28:15 +00:00
|
|
|
|
|
|
|
return tile;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-06-02 13:05:41 +00:00
|
|
|
TileIndex GetNorthernBridgeEnd(TileIndex t)
|
|
|
|
{
|
|
|
|
return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t))));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-16 05:28:15 +00:00
|
|
|
TileIndex GetSouthernBridgeEnd(TileIndex t)
|
|
|
|
{
|
|
|
|
return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t)));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-15 16:44:50 +00:00
|
|
|
TileIndex GetOtherBridgeEnd(TileIndex tile)
|
|
|
|
{
|
2006-06-02 13:05:41 +00:00
|
|
|
assert(IsBridgeTile(tile));
|
|
|
|
return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
|
|
|
|
}
|
2006-03-15 16:44:50 +00:00
|
|
|
|
2006-06-02 13:05:41 +00:00
|
|
|
uint GetBridgeHeight(TileIndex tile, Axis a)
|
|
|
|
{
|
|
|
|
uint h, f;
|
|
|
|
uint tileh = GetTileSlope(tile, &h);
|
2006-03-15 16:44:50 +00:00
|
|
|
|
2006-06-02 13:05:41 +00:00
|
|
|
f = GetBridgeFoundation(tileh, a);
|
|
|
|
|
|
|
|
if (f) {
|
|
|
|
if (f < 15) {
|
|
|
|
h += TILE_HEIGHT;
|
|
|
|
tileh = SLOPE_FLAT;
|
|
|
|
} else {
|
|
|
|
tileh = _inclined_tileh[f - 15];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return h + TILE_HEIGHT;
|
2006-03-15 16:44:50 +00:00
|
|
|
}
|