4 * This file is part of OpenTTD.
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.
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.
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/>.
10 /** @file bridge_signal_map.h Map accessor functions for bridge signal simulation. */
12 #ifndef BRIDGE_SIGNAL_MAP_H
13 #define BRIDGE_SIGNAL_MAP_H
15 #include "tile_type.h"
17 #include "signal_type.h"
18 #include "core/bitmath_func.hpp"
21 #include <unordered_map>
23 struct LongBridgeSignalStorage
{
24 std::vector
<uint64
> signal_red_bits
;
27 extern std::unordered_map
<TileIndex
, LongBridgeSignalStorage
> _long_bridge_signal_sim_map
;
29 SignalState
GetBridgeEntranceSimulatedSignalStateExtended(TileIndex t
, uint16 signal
);
31 static inline SignalState
GetBridgeEntranceSimulatedSignalState(TileIndex t
, uint16 signal
)
34 return GB(_m
[t
].m2
, signal
, 1) ? SIGNAL_STATE_RED
: SIGNAL_STATE_GREEN
;
36 return GetBridgeEntranceSimulatedSignalStateExtended(t
, signal
);
40 void SetBridgeEntranceSimulatedSignalStateExtended(TileIndex t
, uint16 signal
, SignalState state
);
42 static inline void SetBridgeEntranceSimulatedSignalState(TileIndex t
, uint16 signal
, SignalState state
)
45 SB(_m
[t
].m2
, signal
, 1, (state
== SIGNAL_STATE_RED
) ? 1 : 0);
47 SetBridgeEntranceSimulatedSignalStateExtended(t
, signal
, state
);
51 void SetAllBridgeEntranceSimulatedSignalsGreenExtended(TileIndex t
);
53 static inline void SetAllBridgeEntranceSimulatedSignalsGreen(TileIndex t
)
55 if (_m
[t
].m2
& 0x8000) {
56 SetAllBridgeEntranceSimulatedSignalsGreenExtended(t
);
62 void ClearBridgeEntranceSimulatedSignalsExtended(TileIndex t
);
64 static inline void ClearBridgeEntranceSimulatedSignals(TileIndex t
)
66 if (_m
[t
].m2
& 0x8000) {
67 ClearBridgeEntranceSimulatedSignalsExtended(t
);
73 void ClearBridgeSimulatedSignalMapping();
75 #endif /* BRIDGE_SIGNAL_MAP_H */