summaryrefslogtreecommitdiff
path: root/src/tunnel_map.h
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2021-01-03 14:40:43 +0100
committerErich Eckner <git@eckner.net>2021-07-21 19:01:16 +0200
commit114be07283e625ba2fc42a895a38d36b2ad4ac33 (patch)
tree90b99a8a3713185707afd7de029a8f15310386d7 /src/tunnel_map.h
parent6c33b4ed284eabebc1077ef4093502b150ec71b8 (diff)
downloadopenttd-chunnel.tar.xz
chunnel patch originalchunnel
Diffstat (limited to 'src/tunnel_map.h')
-rw-r--r--src/tunnel_map.h26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/tunnel_map.h b/src/tunnel_map.h
index c347626d5..45589dacb 100644
--- a/src/tunnel_map.h
+++ b/src/tunnel_map.h
@@ -13,6 +13,7 @@
#include "rail_map.h"
#include "road_map.h"
+typedef uint16 TunnelID; ///< Type for the unique identifier of tunnels.
/**
* Is this a tunnel (entrance)?
@@ -36,22 +37,34 @@ static inline bool IsTunnelTile(TileIndex t)
return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
}
+/**
+ * Get the index of tunnel tile.
+ * @param t the tile
+ * @pre IsTunnelTile(t)
+ * @return TunnelID
+ */
+static inline TunnelID GetTunnelIndex(TileIndex t)
+{
+ assert(IsTunnelTile(t));
+ return _m[t].m2;
+}
+
TileIndex GetOtherTunnelEnd(TileIndex);
-bool IsTunnelInWay(TileIndex, int z);
-bool IsTunnelInWayDir(TileIndex tile, int z, DiagDirection dir);
+bool IsTunnelInWay(TileIndex, int z, bool chunnel_allowed = false);
/**
* Makes a road tunnel entrance
* @param t the entrance of the tunnel
* @param o the owner of the entrance
+ * @param id the tunnel ID
* @param d the direction facing out of the tunnel
* @param r the road type used in the tunnel
*/
-static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
+static inline void MakeRoadTunnel(TileIndex t, Owner o, TunnelID id, DiagDirection d, RoadType road_rt, RoadType tram_rt)
{
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
- _m[t].m2 = 0;
+ _m[t].m2 = id;
_m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = TRANSPORT_ROAD << 2 | d;
@@ -67,14 +80,15 @@ static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTyp
* Makes a rail tunnel entrance
* @param t the entrance of the tunnel
* @param o the owner of the entrance
+ * @param id the tunnel ID
* @param d the direction facing out of the tunnel
* @param r the rail type used in the tunnel
*/
-static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
+static inline void MakeRailTunnel(TileIndex t, Owner o, TunnelID id, DiagDirection d, RailType r)
{
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
- _m[t].m2 = 0;
+ _m[t].m2 = id;
_m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = TRANSPORT_RAIL << 2 | d;