2006-03-15 16:44:50 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-02-23 11:50:43 +00:00
|
|
|
/** @file bridge_map.cpp */
|
|
|
|
|
2006-03-15 16:44:50 +00:00
|
|
|
#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;
|
2007-01-10 18:56:51 +00:00
|
|
|
Slope tileh = GetTileSlope(t, &h);
|
2006-12-27 12:38:02 +00:00
|
|
|
uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t)));
|
|
|
|
|
2007-02-23 11:50:43 +00:00
|
|
|
/* one height level extra if the ramp is on a flat foundation */
|
2006-12-27 12:38:02 +00:00
|
|
|
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
|
|
|
}
|