diff options
author | glx22 <glx@openttd.org> | 2021-06-13 05:15:36 +0200 |
---|---|---|
committer | Loïc Guilloux <glx22@users.noreply.github.com> | 2021-07-09 21:36:09 +0200 |
commit | 49b66ea504fafe9b942b35a97c369c4afa054f41 (patch) | |
tree | 55441ecb7e10afa37d003239abf7ec5aad97a71f | |
parent | a543a4b7bb0d869800591ec1504b3934b68ecd8f (diff) | |
download | openttd-49b66ea504fafe9b942b35a97c369c4afa054f41.tar.xz |
Codechange: Remove FOR_EACH_SET_TRACK
-rw-r--r-- | src/elrail.cpp | 3 | ||||
-rw-r--r-- | src/pathfinder/follow_track.hpp | 3 | ||||
-rw-r--r-- | src/pathfinder/npf/npf.cpp | 3 | ||||
-rw-r--r-- | src/track_func.h | 11 | ||||
-rw-r--r-- | src/train_cmd.cpp | 3 |
5 files changed, 5 insertions, 18 deletions
diff --git a/src/elrail.cpp b/src/elrail.cpp index 4959bb2cb..03adb0c8c 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -470,8 +470,7 @@ static void DrawRailCatenaryRailway(const TileInfo *ti) } /* Drawing of pylons is finished, now draw the wires */ - Track t; - FOR_EACH_SET_TRACK(t, wireconfig[TS_HOME]) { + for (Track t : SetTrackBitIterator(wireconfig[TS_HOME])) { SpriteID wire_base = (t == halftile_track) ? wire_halftile : wire_normal; byte PCPconfig = HasBit(PCPstatus, PCPpositions[t][0]) + (HasBit(PCPstatus, PCPpositions[t][1]) << 1); diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp index 7e5e0e39b..a9a51da68 100644 --- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -184,8 +184,7 @@ struct CFollowTrackT /* Mask already reserved trackdirs. */ m_new_td_bits &= ~TrackBitsToTrackdirBits(reserved); /* Mask out all trackdirs that conflict with the reservation. */ - Track t; - FOR_EACH_SET_TRACK(t, TrackdirBitsToTrackBits(m_new_td_bits)) { + for (Track t : SetTrackBitIterator(TrackdirBitsToTrackBits(m_new_td_bits))) { if (TracksOverlap(reserved | TrackToTrackBits(t))) m_new_td_bits &= ~TrackToTrackdirBits(t); } if (m_new_td_bits == TRACKDIR_BIT_NONE) { diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 588718185..24803fb31 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -954,8 +954,7 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current) TrackBits reserved = GetReservedTrackbits(dst_tile); trackdirbits &= ~TrackBitsToTrackdirBits(reserved); - Track t; - FOR_EACH_SET_TRACK(t, TrackdirBitsToTrackBits(trackdirbits)) { + for (Track t : SetTrackBitIterator(TrackdirBitsToTrackBits(trackdirbits))) { if (TracksOverlap(reserved | TrackToTrackBits(t))) trackdirbits &= ~TrackToTrackdirBits(t); } } diff --git a/src/track_func.h b/src/track_func.h index 1b5666878..646745064 100644 --- a/src/track_func.h +++ b/src/track_func.h @@ -15,16 +15,7 @@ #include "direction_func.h" #include "slope_func.h" -/** - * Iterate through each set Track in a TrackBits value. - * For more information see FOR_EACH_SET_BIT_EX. - * - * @param var Loop index variable that stores fallowing set track. Must be of type Track. - * @param track_bits The value to iterate through (any expression). - * - * @see FOR_EACH_SET_BIT_EX - */ -#define FOR_EACH_SET_TRACK(var, track_bits) FOR_EACH_SET_BIT_EX(Track, var, TrackBits, track_bits) +using SetTrackBitIterator = SetBitIterator<Track, TrackBits>; /** * Checks if a Track is valid. diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 47895122b..17e298c33 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3485,8 +3485,7 @@ static void DeleteLastWagon(Train *v) /* It is important that these two are the first in the loop, as reservation cannot deal with every trackbit combination */ assert(TRACK_BEGIN == TRACK_X && TRACK_Y == TRACK_BEGIN + 1); - Track t; - FOR_EACH_SET_TRACK(t, remaining_trackbits) TryReserveRailTrack(tile, t); + for (Track t : SetTrackBitIterator(remaining_trackbits)) TryReserveRailTrack(tile, t); } /* check if the wagon was on a road/rail-crossing */ |