OpenTTD
tunnelbridge.h
Go to the documentation of this file.
1 /* $Id$ */
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 #include "tile_map.h"
17 
18 void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height);
19 void MarkBridgeDirty(TileIndex tile);
20 
27 static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
28 {
29  int x1 = TileX(begin);
30  int y1 = TileY(begin);
31  int x2 = TileX(end);
32  int y2 = TileY(end);
33 
34  return abs(x2 + y2 - x1 - y1) - 1;
35 }
36 
43 static inline void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
44 {
45  SetTileOwner(begin, owner);
46  SetTileOwner(end, owner);
47 }
48 
50 
51 #endif /* TUNNELBRIDGE_H */
Owner
Enum for all companies/owners.
Definition: company_type.h:20
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
Definition: tile_map.h:200
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:27
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
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
DiagDirection
Enumeration for diagonal directions.
static void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
Sets the ownership of the bridge/tunnel ramps.
Definition: tunnelbridge.h:43
Map writing/reading functions for tiles.