OpenTTD Source: src/tunnelbridge.h Source File

OpenTTD Source 1.11.0-RC1

tunnelbridge.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10 #ifndef TUNNELBRIDGE_H
11 #define TUNNELBRIDGE_H
12
13 #include "map_func.h"
14 #include "tile_map.h"
15
16 void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height);
17 void MarkBridgeDirty(TileIndex tile);
18
25 static inline uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
26 {
27 int x1 = TileX(begin);
28 int y1 = TileY(begin);
29 int x2 = TileX(end);
30 int y2 = TileY(end);
31
32 return abs(x2 + y2 - x1 - y1) - 1;
33 }
34
41 static inline void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
42 {
43 SetTileOwner(begin, owner);
44 SetTileOwner(end, owner);
45 }
46
47 extern TileIndex _build_tunnel_endtile;
48
49 #endif /* TUNNELBRIDGE_H */
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
map_func.h
TileY
static uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:215
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
TileX
static uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:205
SetTunnelBridgeOwner
static void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
Sets the ownership of the bridge/tunnel ramps.
Definition: tunnelbridge.h:41
tile_map.h
MarkBridgeDirty
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
Definition: tunnelbridge_cmd.cpp:64
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
_build_tunnel_endtile
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Definition: tunnelbridge_cmd.cpp:50
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
GetTunnelBridgeLength
static uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
Definition: tunnelbridge.h:25
SetTileOwner
static void SetTileOwner(TileIndex tile, Owner owner)
Sets the owner of a tile.
Definition: tile_map.h:198