diff options
Diffstat (limited to 'src/rail_map.h')
-rw-r--r-- | src/rail_map.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rail_map.h b/src/rail_map.h index 9b9bc16ef..d4f63c72b 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -375,6 +375,18 @@ static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trac SIGNAL_STATE_GREEN : SIGNAL_STATE_RED; } +/** + * Sets the state of the signal along the given trackdir. + */ +static inline void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state) +{ + if (state == SIGNAL_STATE_GREEN) { // set 1 + SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir)); + } else { + SetSignalStates(tile, GetSignalStates(tile) & ~SignalAlongTrackdir(trackdir)); + } +} + /** * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile. |