summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-15 17:10:46 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit60e3cf8aff9a7b98a0365ab734bebf70607160a1 (patch)
treedac5e2054f6666dff239e6c441bd238ced7bb8ca
parentddabfed1cd3efa9ee229214207a60fc7cb3e0641 (diff)
downloadopenttd-60e3cf8aff9a7b98a0365ab734bebf70607160a1.tar.xz
Codechange: Replace FOR_ALL_ENGINE_RENEWS with range-based for loops
-rw-r--r--src/autoreplace_base.h3
-rw-r--r--src/group_cmd.cpp3
-rw-r--r--src/saveload/autoreplace_sl.cpp8
3 files changed, 3 insertions, 11 deletions
diff --git a/src/autoreplace_base.h b/src/autoreplace_base.h
index d7295a4db..c342223a7 100644
--- a/src/autoreplace_base.h
+++ b/src/autoreplace_base.h
@@ -41,7 +41,4 @@ struct EngineRenew : EngineRenewPool::PoolItem<&_enginerenew_pool> {
~EngineRenew() {}
};
-#define FOR_ALL_ENGINE_RENEWS_FROM(var, start) FOR_ALL_ITEMS_FROM(EngineRenew, enginerenew_index, var, start)
-#define FOR_ALL_ENGINE_RENEWS(var) FOR_ALL_ENGINE_RENEWS_FROM(var, 0)
-
#endif /* AUTOREPLACE_BASE_H */
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index 95b7070c7..e16d03620 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -384,10 +384,9 @@ CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* If we set an autoreplace for the group we delete, remove it. */
if (_current_company < MAX_COMPANIES) {
Company *c;
- EngineRenew *er;
c = Company::Get(_current_company);
- FOR_ALL_ENGINE_RENEWS(er) {
+ for (EngineRenew *er : EngineRenew::Iterate()) {
if (er->group_id == g->index) RemoveEngineReplacementForCompany(c, er->from, g->index, flags);
}
}
diff --git a/src/saveload/autoreplace_sl.cpp b/src/saveload/autoreplace_sl.cpp
index abfd32755..88f925cc5 100644
--- a/src/saveload/autoreplace_sl.cpp
+++ b/src/saveload/autoreplace_sl.cpp
@@ -26,9 +26,7 @@ static const SaveLoad _engine_renew_desc[] = {
static void Save_ERNW()
{
- EngineRenew *er;
-
- FOR_ALL_ENGINE_RENEWS(er) {
+ for (EngineRenew *er : EngineRenew::Iterate()) {
SlSetArrayIndex(er->index);
SlObject(er, _engine_renew_desc);
}
@@ -53,9 +51,7 @@ static void Load_ERNW()
static void Ptrs_ERNW()
{
- EngineRenew *er;
-
- FOR_ALL_ENGINE_RENEWS(er) {
+ for (EngineRenew *er : EngineRenew::Iterate()) {
SlObject(er, _engine_renew_desc);
}
}