OpenTTD
tunnelbridge.h
Go to the documentation of this file.
1 /* $Id: tunnelbridge.h 27157 2015-02-22 14:01:24Z frosch $ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * 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.
6  * 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.
7  * 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/>.
8  */
9 
12 #ifndef TUNNELBRIDGE_H
13 #define TUNNELBRIDGE_H
14 
15 #include "map_func.h"
16 
17 void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height);
18 void MarkBridgeDirty(TileIndex tile);
19 
26 static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
27 {
28  int x1 = TileX(begin);
29  int y1 = TileY(begin);
30  int x2 = TileX(end);
31  int y2 = TileY(end);
32 
33  return abs(x2 + y2 - x1 - y1) - 1;
34 }
35 
37 
38 #endif /* TUNNELBRIDGE_H */
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:207
Functions related to maps.
static uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
Definition: tunnelbridge.h:26
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
DiagDirection
Enumeration for diagonal directions.
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:217
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:83