OpenTTD Source  20241108-master-g80f628063a
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 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 inline void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
42 {
43  SetTileOwner(begin, owner);
44  SetTileOwner(end, owner);
45 }
46 
48 
49 #endif /* TUNNELBRIDGE_H */
Owner
Enum for all companies/owners.
Definition: company_type.h:18
DiagDirection
Enumeration for diagonal directions.
Functions related to maps.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:425
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:415
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:23
Map writing/reading functions for tiles.
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
Definition: tile_map.h:198
void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
Sets the ownership of the bridge/tunnel ramps.
Definition: tunnelbridge.h:41
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
Definition: tunnelbridge.h:25
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.