annotate src/tunnelbridge_map.h @ 12778:bc7926153e19 draft

(svn r17248) -Fix: add GPL license notice where appropriate
author rubidium <rubidium@openttd.org>
date Fri, 21 Aug 2009 20:21:05 +0000
parents 299da608443d
children a899d4e5ee1a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
1 /* $Id$ */
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12470
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12470
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12470
diff changeset
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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12470
diff changeset
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.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12470
diff changeset
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/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12470
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12470
diff changeset
9
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
10 /** @file tunnelbridge_map.h Functions that have tunnels and bridges in common */
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
11
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
12 #ifndef TUNNELBRIDGE_MAP_H
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
13 #define TUNNELBRIDGE_MAP_H
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
14
8100
6d739a5490a9 (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium <rubidium@openttd.org>
parents: 8083
diff changeset
15 #include "direction_func.h"
8139
db99ba38abc0 (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents: 8108
diff changeset
16 #include "core/bitmath_func.hpp"
db99ba38abc0 (svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents: 8108
diff changeset
17 #include "tile_map.h"
8197
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
18 #include "bridge_map.h"
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
19 #include "tunnel_map.h"
9126
8c450e1754e2 (svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium <rubidium@openttd.org>
parents: 8481
diff changeset
20 #include "transport_type.h"
9784
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
21 #include "track_func.h"
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
22
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
23
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
24 /**
8481
ea213e172131 (svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch <frosch@openttd.org>
parents: 8197
diff changeset
25 * Get the direction pointing to the other end.
ea213e172131 (svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch <frosch@openttd.org>
parents: 8197
diff changeset
26 *
ea213e172131 (svn r12056) -Fix [FS#1704]: Enable YAPF to start searching inside a wormhole.
frosch <frosch@openttd.org>
parents: 8197
diff changeset
27 * Tunnel: Get the direction facing into the tunnel
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
28 * Bridge: Get the direction pointing onto the bridge
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
29 * @param t The tile to analyze
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
30 * @pre IsTileType(t, MP_TUNNELBRIDGE)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
31 * @return the above mentionned direction
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
32 */
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
33 static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
34 {
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
35 assert(IsTileType(t, MP_TUNNELBRIDGE));
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
36 return (DiagDirection)GB(_m[t].m5, 0, 2);
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
37 }
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
38
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
39 /**
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
40 * Tunnel: Get the transport type of the tunnel (road or rail)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
41 * Bridge: Get the transport type of the bridge's ramp
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
42 * @param t The tile to analyze
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
43 * @pre IsTileType(t, MP_TUNNELBRIDGE)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
44 * @return the transport type in the tunnel/bridge
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
45 */
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
46 static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
47 {
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
48 assert(IsTileType(t, MP_TUNNELBRIDGE));
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
49 return (TransportType)GB(_m[t].m5, 2, 2);
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
50 }
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
51
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
52 /**
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
53 * Tunnel: Is this tunnel entrance in a snowy or desert area?
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
54 * Bridge: Does the bridge ramp lie in a snow or desert area?
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
55 * @param t The tile to analyze
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
56 * @pre IsTileType(t, MP_TUNNELBRIDGE)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
57 * @return true if and only if the tile is in a snowy/desert area
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
58 */
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
59 static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
60 {
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
61 assert(IsTileType(t, MP_TUNNELBRIDGE));
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 9784
diff changeset
62 return HasBit(_me[t].m7, 5);
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
63 }
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
64
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
65 /**
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
66 * Tunnel: Places this tunnel entrance in a snowy or desert area, or takes it out of there.
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
67 * Bridge: Sets whether the bridge ramp lies in a snow or desert area.
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
68 * @param t the tunnel entrance / bridge ramp tile
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
69 * @param snow_or_desert is the entrance/ramp in snow or desert (true), when
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
70 * not in snow and not in desert false
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
71 * @pre IsTileType(t, MP_TUNNELBRIDGE)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
72 */
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
73 static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
74 {
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
75 assert(IsTileType(t, MP_TUNNELBRIDGE));
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 9784
diff changeset
76 SB(_me[t].m7, 5, 1, snow_or_desert);
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
77 }
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
78
8197
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
79 /**
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
80 * Determines type of the wormhole and returns its other end
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
81 * @param t one end
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
82 * @pre IsTileType(t, MP_TUNNELBRIDGE)
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
83 * @return other end
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
84 */
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
85 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
86 {
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
87 assert(IsTileType(t, MP_TUNNELBRIDGE));
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
88 return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
89 }
bdb186c8fe93 (svn r11760) -Codechange: unify the way how other end of a tunnel/bridge is determined at some places
smatz <smatz@openttd.org>
parents: 8142
diff changeset
90
9784
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
91
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
92 /**
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
93 * Get the reservation state of the rail tunnel/bridge
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
94 * @pre IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
95 * @param t the tile
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
96 * @return reservation state
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
97 */
12470
299da608443d (svn r16907) -Codechange: make a more clear distinction between reservation functions that return a bool and that return TrackBits; GetRailStationReservation vs GetRailwayStationReservation, which one returns the bool and which one the TrackBits?
rubidium <rubidium@openttd.org>
parents: 11252
diff changeset
98 static inline bool HasTunnelBridgeReservation(TileIndex t)
9784
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
99 {
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
100 assert(IsTileType(t, MP_TUNNELBRIDGE));
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
101 assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
102 return HasBit(_m[t].m5, 4);
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
103 }
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
104
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
105 /**
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
106 * Set the reservation state of the rail tunnel/bridge
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
107 * @pre IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
108 * @param t the tile
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
109 * @param b the reservation state
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
110 */
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
111 static inline void SetTunnelBridgeReservation(TileIndex t, bool b)
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
112 {
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
113 assert(IsTileType(t, MP_TUNNELBRIDGE));
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
114 assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
115 SB(_m[t].m5, 4, 1, b ? 1 : 0);
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
116 }
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
117
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
118 /**
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
119 * Get the reserved track bits for a rail tunnel/bridge
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
120 * @pre IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
121 * @param t the tile
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
122 * @return reserved track bits
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
123 */
12470
299da608443d (svn r16907) -Codechange: make a more clear distinction between reservation functions that return a bool and that return TrackBits; GetRailStationReservation vs GetRailwayStationReservation, which one returns the bool and which one the TrackBits?
rubidium <rubidium@openttd.org>
parents: 11252
diff changeset
124 static inline TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
9784
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
125 {
12470
299da608443d (svn r16907) -Codechange: make a more clear distinction between reservation functions that return a bool and that return TrackBits; GetRailStationReservation vs GetRailwayStationReservation, which one returns the bool and which one the TrackBits?
rubidium <rubidium@openttd.org>
parents: 11252
diff changeset
126 return HasTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
9784
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
127 }
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9126
diff changeset
128
8083
e02014b06c7f (svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz <smatz@openttd.org>
parents:
diff changeset
129 #endif /* TUNNELBRIDGE_MAP_H */