2006-03-15 16:44:50 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "openttd.h"
|
|
|
|
#include "bridge_map.h"
|
2006-12-27 12:38:02 +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)
|
|
|
|
{
|
2006-09-05 23:21:41 +00:00
|
|
|
TileIndexDiff delta = TileOffsByDiagDir(dir);
|
2006-03-16 05:28:15 +00:00
|
|
|
|
2006-12-27 12:38:02 +00:00
|
|
|
dir = ReverseDiagDir(dir);
|
2006-06-07 19:35:21 +00:00
|
|
|
do {
|
|
|
|
tile += delta;
|
2006-12-27 12:38:02 +00:00
|
|
|
} while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir);
|
2006-03-16 05:28:15 +00:00
|
|
|
|
2006-06-07 19:35:21 +00:00
|
|
|
return tile;
|
2006-06-02 13:05:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-12-27 12:38:02 +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-12-27 12:38:02 +00:00
|
|
|
assert(IsBridgeTile(tile));
|
|
|
|
return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
|
|
|
|
}
|
2006-06-02 13:05:41 +00:00
|
|
|
|
2006-12-27 12:38:02 +00:00
|
|
|
uint GetBridgeHeight(TileIndex t)
|
|
|
|
{
|
|
|
|
uint h;
|
|
|
|
uint tileh = GetTileSlope(t, &h);
|
|
|
|
uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
|
|
|
|
|
|
|
|
// one height level extra if the ramp is on a flat foundation
|
|
|
|
return
|
|
|
|
h + TILE_HEIGHT +
|
|
|
|
(IS_INT_INSIDE(f, 1, 15) ? TILE_HEIGHT : 0) +
|
|
|
|
(IsSteepSlope(tileh) ? TILE_HEIGHT : 0);
|
2006-03-15 16:44:50 +00:00
|
|
|
}
|