diff options
author | glx <glx@openttd.org> | 2019-12-15 05:55:59 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | ddabfed1cd3efa9ee229214207a60fc7cb3e0641 (patch) | |
tree | 824eddd3155d04363864731a43a6863cd7fbd2a3 /src/base_station_base.h | |
parent | 3a14cea068d130e11b5d9dde11d4451dd7dec453 (diff) | |
download | openttd-ddabfed1cd3efa9ee229214207a60fc7cb3e0641.tar.xz |
Codechange: Replace station related FOR_ALL with range-based for loops
Diffstat (limited to 'src/base_station_base.h')
-rw-r--r-- | src/base_station_base.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/base_station_base.h b/src/base_station_base.h index a23a7bf51..a1c935fce 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -163,8 +163,6 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { static void PostDestructor(size_t index); }; -#define FOR_ALL_BASE_STATIONS(var) FOR_ALL_ITEMS_FROM(BaseStation, station_index, var, 0) - /** * Class defining several overloaded accessors so we don't * have to cast base stations that often @@ -252,8 +250,13 @@ struct SpecializedStation : public BaseStation { assert(IsExpected(st)); return (const T *)st; } -}; -#define FOR_ALL_BASE_STATIONS_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, station_index, var, 0) if (name::IsExpected(var)) + /** + * Returns an iterable ensemble of all valid stations of type T + * @param from index of the first station to consider + * @return an iterable ensemble of all valid stations of type T + */ + static Pool::IterateWrapper<T> Iterate(size_t from = 0) { return Pool::IterateWrapper<T>(from); } +}; #endif /* BASE_STATION_BASE_H */ |