summaryrefslogtreecommitdiff
path: root/src/saveload
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-17 19:05:46 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit514565fad6d3a7e93a24b53b29eb901ef4f6a166 (patch)
treebadaf632dd5047e6be442e606bee956184845479 /src/saveload
parent11f178a312d1a601aa14f9188f05f4a4cd033cf9 (diff)
downloadopenttd-514565fad6d3a7e93a24b53b29eb901ef4f6a166.tar.xz
Codechange: Replace FOR_ALL_OBJECTS with range-based for loops
Diffstat (limited to 'src/saveload')
-rw-r--r--src/saveload/afterload.cpp6
-rw-r--r--src/saveload/object_sl.cpp7
2 files changed, 4 insertions, 9 deletions
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index 8df01bc58..d175b612f 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -253,8 +253,7 @@ static void InitializeWindowsAndCaches()
}
/* Count number of objects per type */
- Object *o;
- FOR_ALL_OBJECTS(o) {
+ for (Object *o : Object::Iterate()) {
Object::IncTypeCount(o->type);
}
@@ -2474,8 +2473,7 @@ bool AfterLoadGame()
/* Add (random) colour to all objects. */
if (IsSavegameVersionBefore(SLV_148)) {
- Object *o;
- FOR_ALL_OBJECTS(o) {
+ for (Object *o : Object::Iterate()) {
Owner owner = GetTileOwner(o->location.tile);
o->colour = (owner == OWNER_NONE) ? Random() & 0xF : Company::Get(owner)->livery->colour1;
}
diff --git a/src/saveload/object_sl.cpp b/src/saveload/object_sl.cpp
index b0c4e7513..2c385b655 100644
--- a/src/saveload/object_sl.cpp
+++ b/src/saveload/object_sl.cpp
@@ -31,10 +31,8 @@ static const SaveLoad _object_desc[] = {
static void Save_OBJS()
{
- Object *o;
-
/* Write the objects */
- FOR_ALL_OBJECTS(o) {
+ for (Object *o : Object::Iterate()) {
SlSetArrayIndex(o->index);
SlObject(o, _object_desc);
}
@@ -51,8 +49,7 @@ static void Load_OBJS()
static void Ptrs_OBJS()
{
- Object *o;
- FOR_ALL_OBJECTS(o) {
+ for (Object *o : Object::Iterate()) {
SlObject(o, _object_desc);
if (IsSavegameVersionBefore(SLV_148) && !IsTileType(o->location.tile, MP_OBJECT)) {
/* Due to a small bug stale objects could remain. */