OpenTTD Source  20240917-master-g9ab0a47812
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 */
TileY
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
Definition: map_func.h:437
GetTunnelBridgeLength
uint GetTunnelBridgeLength(TileIndex begin, TileIndex end)
Calculates the length of a tunnel or a bridge (without end tiles)
Definition: tunnelbridge.h:25
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
map_func.h
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:73
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
tile_map.h
MarkBridgeDirty
void MarkBridgeDirty(TileIndex begin, TileIndex end, DiagDirection direction, uint bridge_height)
Mark bridge tiles dirty.
Definition: tunnelbridge_cmd.cpp:67
SetTunnelBridgeOwner
void SetTunnelBridgeOwner(TileIndex begin, TileIndex end, Owner owner)
Sets the ownership of the bridge/tunnel ramps.
Definition: tunnelbridge.h:41
SetTileOwner
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
Definition: tile_map.h:198
abs
constexpr T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:23
_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:53
TileX
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
Definition: map_func.h:427