summaryrefslogtreecommitdiff
path: root/bridge_map.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-06-02 13:05:41 +0000
committercelestar <celestar@openttd.org>2006-06-02 13:05:41 +0000
commitb618b75c9b189b13c296cff78d4f070c52fae035 (patch)
treed5df4e2831609eca45d7ea4558e09a600089ead2 /bridge_map.c
parent7e6d84a34ec91e27c3c1653061f043b68cc29bac (diff)
downloadopenttd-b618b75c9b189b13c296cff78d4f070c52fae035.tar.xz
(svn r5070) Merged the bridge branch
-Feature: Bridges can now be placed above: Any railway track combination (excluding depots and waypoints) Any road combination (excluding depots) Clear tiles (duh), including fields Tunnel entrances Bridge heads Thanks to Tron for idea and implementation, KUDr for the yapf synchronization and many others for hours of testing There are still a number of visual problems remaining, especially when electric railways are on or under the bridge. DO NOT REPORT THOSE BUGS FOR THE TIME BEING please.
Diffstat (limited to 'bridge_map.c')
-rw-r--r--bridge_map.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/bridge_map.c b/bridge_map.c
index cbb955c37..e21c5928c 100644
--- a/bridge_map.c
+++ b/bridge_map.c
@@ -3,22 +3,25 @@
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
+#include "variables.h"
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
{
TileIndexDiff delta = TileOffsByDir(dir);
- assert(DiagDirToAxis(dir) == GetBridgeAxis(tile));
-
- do {
- tile += delta;
- } while (!IsBridgeRamp(tile));
+ do { tile += delta; } while (IsBridgeAbove(tile) && IsBridgeOfAxis(tile, DiagDirToAxis(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 +30,25 @@ TileIndex GetSouthernBridgeEnd(TileIndex t)
TileIndex GetOtherBridgeEnd(TileIndex tile)
{
- TileIndexDiff delta = TileOffsByDir(GetBridgeRampDirection(tile));
+ assert(IsBridgeTile(tile));
+ return GetBridgeEnd(tile, GetBridgeRampDirection(tile));
+}
- do {
- tile += delta;
- } while (!IsBridgeRamp(tile));
+uint GetBridgeHeight(TileIndex tile, Axis a)
+{
+ uint h, f;
+ uint tileh = GetTileSlope(tile, &h);
- return tile;
+ 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;
}