diff options
author | J0anJosep <juanjo.ng.83@gmail.com> | 2018-05-12 18:19:40 +0200 |
---|---|---|
committer | frosch <github@elsenhans.name> | 2018-06-27 23:14:30 +0200 |
commit | d01c09fb73aacd1b3c204829e7c574bbde09153f (patch) | |
tree | 5327845c01eeba8864925a38d97ab210b58f1850 /src/track_func.h | |
parent | 31ac11bddb71945bba57d0cefac620f455963455 (diff) | |
download | openttd-d01c09fb73aacd1b3c204829e7c574bbde09153f.tar.xz |
Codechange: Use HasTrack(dir) to improve code readability.
Diffstat (limited to 'src/track_func.h')
-rw-r--r-- | src/track_func.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/track_func.h b/src/track_func.h index c1a23ba03..8e2056265 100644 --- a/src/track_func.h +++ b/src/track_func.h @@ -332,6 +332,28 @@ static inline TrackdirBits TrackBitsToTrackdirBits(TrackBits bits) } /** + * Checks whether a TrackBits has a given Track. + * @param tracks The track bits. + * @param track The track to check. + */ +static inline bool HasTrack(TrackBits tracks, Track track) +{ + assert(IsValidTrack(track)); + return HasBit(tracks, track); +} + +/** + * Checks whether a TrackdirBits has a given Trackdir. + * @param trackdirs The trackdir bits. + * @param trackdir The trackdir to check. + */ +static inline bool HasTrackdir(TrackdirBits trackdirs, Trackdir trackdir) +{ + assert(IsValidTrackdir(trackdir)); + return HasBit(trackdirs, trackdir); +} + +/** * Returns the present-trackdir-information of a TrackStatus. * * @param ts The TrackStatus returned by GetTileTrackStatus() |