2006-03-15 16:44:50 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2007-04-03 21:51:40 +00:00
|
|
|
/** @file bridge_map.cpp Map accessor functions for bridges. */
|
2007-02-23 11:50:43 +00:00
|
|
|
|
2006-03-15 16:44:50 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "bridge_map.h"
|
2007-10-20 16:50:48 +00:00
|
|
|
#include "landscape.h"
|
2007-12-16 15:38:51 +00:00
|
|
|
#include "tunnelbridge_map.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;
|
2007-12-16 15:38:51 +00:00
|
|
|
} while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(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));
|
2007-12-16 15:38:51 +00:00
|
|
|
return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
|
2006-12-27 12:38:02 +00:00
|
|
|
}
|
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);
|
2007-12-16 15:38:51 +00:00
|
|
|
Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
|
2006-12-27 12:38:02 +00:00
|
|
|
|
2007-10-20 16:50:48 +00:00
|
|
|
/* one height level extra for the ramp */
|
|
|
|
return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh);
|
2006-03-15 16:44:50 +00:00
|
|
|
}
|