Mercurial > hg > openttd
view src/bridge_map.cpp @ 13044:1f4a5608aba5 draft
(svn r17542) -Fix: don't access variables in the company struct after it has been deleted
-Cleanup: remove some never-used code
author | yexo <yexo@openttd.org> |
---|---|
date | Mon, 14 Sep 2009 22:09:50 +0000 |
parents | bc7926153e19 |
children | afdfdda87cd4 |
line wrap: on
line source
/* $Id$ */ /* * This file is part of OpenTTD. * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2. * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>. */ /** @file bridge_map.cpp Map accessor functions for bridges. */ #include "stdafx.h" #include "bridge_map.h" #include "landscape.h" #include "tunnelbridge_map.h" TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir) { TileIndexDiff delta = TileOffsByDiagDir(dir); dir = ReverseDiagDir(dir); do { tile += delta; } while (!IsBridgeTile(tile) || GetTunnelBridgeDirection(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))); } TileIndex GetOtherBridgeEnd(TileIndex tile) { assert(IsBridgeTile(tile)); return GetBridgeEnd(tile, GetTunnelBridgeDirection(tile)); } uint GetBridgeHeight(TileIndex t) { uint h; Slope tileh = GetTileSlope(t, &h); Foundation f = GetBridgeFoundation(tileh, DiagDirToAxis(GetTunnelBridgeDirection(t))); /* one height level extra for the ramp */ return h + TILE_HEIGHT + ApplyFoundationToSlope(f, &tileh); }