# bridge_map.cpp

Go to the documentation of this file.

    00001 /* $Id: bridge_map.cpp 11644 2007-12-16 15:38:51Z smatz $ */
    00002
    00005 #include "stdafx.h"
    00006 #include "openttd.h"
    00007 #include "bridge_map.h"
    00008 #include "bridge.h"
    00009 #include "variables.h"
    00010 #include "landscape.h"
    00011 #include "tunnelbridge_map.h"
    00012
    00013
    00014 TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
    00015 {
    00016   TileIndexDiff delta = TileOffsByDiagDir(dir);
    00017
    00018   dir = ReverseDiagDir(dir);
    00019   do {
    00020     tile += delta;
    00021   } while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(tile) != dir);
    00022
    00023   return tile;
    00024 }
    00025
    00026
    00027 TileIndex GetNorthernBridgeEnd(TileIndex t)
    00028 {
    00029   return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t))));
    00030 }
    00031
    00032
    00033 TileIndex GetSouthernBridgeEnd(TileIndex t)
    00034 {
    00035   return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t)));
    00036 }
    00037
    00038
    00039 TileIndex GetOtherBridgeEnd(TileIndex tile)
    00040 {
    00041   assert(IsBridgeTile(tile));
    00042   return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile));
    00043 }
    00044
    00045 uint GetBridgeHeight(TileIndex t)
    00046 {
    00047   uint h;
    00048   Slope tileh = GetTileSlope(t, &h);
    00049   Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t)));
    00050
    00051   /* one height level extra for the ramp */
    00052   return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh);
    00053 }