# bridge_map.cpp

Go to the documentation of this file.

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