forked from mirror/OpenTTD
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
This commit is contained in:
34
bridge_map.c
34
bridge_map.c
@@ -3,22 +3,28 @@
|
||||
#include "stdafx.h"
|
||||
#include "openttd.h"
|
||||
#include "bridge_map.h"
|
||||
#include "variables.h"
|
||||
|
||||
|
||||
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
|
||||
{
|
||||
TileIndexDiff delta = TileOffsByDiagDir(dir);
|
||||
|
||||
assert(DiagDirToAxis(dir) == GetBridgeAxis(tile));
|
||||
|
||||
dir = ReverseDiagDir(dir);
|
||||
do {
|
||||
tile += delta;
|
||||
} while (!IsBridgeRamp(tile));
|
||||
} while (!IsBridgeTile(tile) || GetBridgeRampDirection(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)));
|
||||
@@ -27,11 +33,19 @@ TileIndex GetSouthernBridgeEnd(TileIndex t)
|
||||
|
||||
TileIndex GetOtherBridgeEnd(TileIndex tile)
|
||||
{
|
||||
TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
|
||||
|
||||
do {
|
||||
tile += delta;
|
||||
} while (!IsBridgeRamp(tile));
|
||||
|
||||
return tile;
|
||||
assert(IsBridgeTile(tile));
|
||||
return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user