summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-17 19:14:42 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit869581eb238b820574d64cd8dabc9324cd7a0dd5 (patch)
treeb6d3937c8da8ad0f3b477601bb01e05d4c647cec
parentb91abd3af98cca51221210198e2c9607055c19b2 (diff)
downloadopenttd-869581eb238b820574d64cd8dabc9324cd7a0dd5.tar.xz
Codechange: Replace FOR_ALL_SIGNS with range-based for loops
-rw-r--r--src/economy.cpp3
-rw-r--r--src/saveload/afterload.cpp3
-rw-r--r--src/saveload/signs_sl.cpp4
-rw-r--r--src/script/api/script_signlist.cpp3
-rw-r--r--src/signs.cpp4
-rw-r--r--src/signs_base.h3
-rw-r--r--src/signs_gui.cpp3
-rw-r--r--src/viewport.cpp3
8 files changed, 7 insertions, 19 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index a4e476537..b4a7d6809 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -521,8 +521,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
}
}
- Sign *si;
- FOR_ALL_SIGNS(si) {
+ for (Sign *si : Sign::Iterate()) {
if (si->owner == old_owner) si->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
}
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index d175b612f..f4e81b75b 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1990,8 +1990,7 @@ bool AfterLoadGame()
UpdateNearestTownForRoadTiles(false);
/* signs with invalid owner left from older savegames */
- Sign *si;
- FOR_ALL_SIGNS(si) {
+ for (Sign *si : Sign::Iterate()) {
if (si->owner != OWNER_NONE && !Company::IsValidID(si->owner)) si->owner = OWNER_NONE;
}
diff --git a/src/saveload/signs_sl.cpp b/src/saveload/signs_sl.cpp
index 33be36d9c..0be96e982 100644
--- a/src/saveload/signs_sl.cpp
+++ b/src/saveload/signs_sl.cpp
@@ -32,9 +32,7 @@ static const SaveLoad _sign_desc[] = {
/** Save all signs */
static void Save_SIGN()
{
- Sign *si;
-
- FOR_ALL_SIGNS(si) {
+ for (Sign *si : Sign::Iterate()) {
SlSetArrayIndex(si->index);
SlObject(si, _sign_desc);
}
diff --git a/src/script/api/script_signlist.cpp b/src/script/api/script_signlist.cpp
index 7288d7568..c64891a90 100644
--- a/src/script/api/script_signlist.cpp
+++ b/src/script/api/script_signlist.cpp
@@ -16,8 +16,7 @@
ScriptSignList::ScriptSignList()
{
- Sign *s;
- FOR_ALL_SIGNS(s) {
+ for (const Sign *s : Sign::Iterate()) {
if (ScriptSign::IsValidSign(s->index)) this->AddItem(s->index);
}
}
diff --git a/src/signs.cpp b/src/signs.cpp
index c42644269..f477ab764 100644
--- a/src/signs.cpp
+++ b/src/signs.cpp
@@ -59,9 +59,7 @@ void Sign::UpdateVirtCoord()
/** Update the coordinates of all signs */
void UpdateAllSignVirtCoords()
{
- Sign *si;
-
- FOR_ALL_SIGNS(si) {
+ for (Sign *si : Sign::Iterate()) {
si->UpdateVirtCoord();
}
}
diff --git a/src/signs_base.h b/src/signs_base.h
index e92a05e2f..6cc7dc6d8 100644
--- a/src/signs_base.h
+++ b/src/signs_base.h
@@ -32,7 +32,4 @@ struct Sign : SignPool::PoolItem<&_sign_pool> {
void UpdateVirtCoord();
};
-#define FOR_ALL_SIGNS_FROM(var, start) FOR_ALL_ITEMS_FROM(Sign, sign_index, var, start)
-#define FOR_ALL_SIGNS(var) FOR_ALL_SIGNS_FROM(var, 0)
-
#endif /* SIGNS_BASE_H */
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 9bd64b7d1..ea3de7008 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -60,8 +60,7 @@ struct SignList {
this->signs.clear();
- const Sign *si;
- FOR_ALL_SIGNS(si) this->signs.push_back(si);
+ for (const Sign *si : Sign::Iterate()) this->signs.push_back(si);
this->signs.SetFilterState(true);
this->FilterSignList();
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 27bbdad51..fa590354b 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2260,8 +2260,7 @@ void RebuildViewportKdtree()
if (town->cache.sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeTown(town->index));
}
- const Sign *sign;
- FOR_ALL_SIGNS(sign) {
+ for (const Sign *sign : Sign::Iterate()) {
if (sign->sign.kdtree_valid) items.push_back(ViewportSignKdtreeItem::MakeSign(sign->index));
}