summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_object.cpp3
-rw-r--r--src/object_base.h3
-rw-r--r--src/object_cmd.cpp3
-rw-r--r--src/saveload/afterload.cpp6
-rw-r--r--src/saveload/object_sl.cpp7
-rw-r--r--src/town_cmd.cpp6
6 files changed, 8 insertions, 20 deletions
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
index 417dc2a4e..34e18c43a 100644
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -186,8 +186,7 @@ static uint32 GetNearbyObjectTileInformation(byte parameter, TileIndex tile, Obj
static uint32 GetClosestObject(TileIndex tile, ObjectType type, const Object *current)
{
uint32 best_dist = UINT32_MAX;
- const Object *o;
- FOR_ALL_OBJECTS(o) {
+ for (const Object *o : Object::Iterate()) {
if (o->type != type || o == current) continue;
best_dist = min(best_dist, DistanceManhattan(tile, o->location.tile));
diff --git a/src/object_base.h b/src/object_base.h
index 1ea5fe09d..a468a01ee 100644
--- a/src/object_base.h
+++ b/src/object_base.h
@@ -78,9 +78,6 @@ protected:
static uint16 counts[NUM_OBJECTS]; ///< Number of objects per type ingame
};
-#define FOR_ALL_OBJECTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Object, object_index, var, start)
-#define FOR_ALL_OBJECTS(var) FOR_ALL_OBJECTS_FROM(var, 0)
-
/**
* Keeps track of removed objects during execution/testruns of commands.
*/
diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp
index 1e34b78d8..3fb61d647 100644
--- a/src/object_cmd.cpp
+++ b/src/object_cmd.cpp
@@ -173,8 +173,7 @@ void UpdateCompanyHQ(TileIndex tile, uint score)
*/
void UpdateObjectColours(const Company *c)
{
- Object *obj;
- FOR_ALL_OBJECTS(obj) {
+ for (Object *obj : Object::Iterate()) {
Owner owner = GetTileOwner(obj->location.tile);
/* Not the current owner, so colour doesn't change. */
if (owner != c->index) continue;
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. */
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index d97dee3b4..3fbf26e1d 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -115,8 +115,7 @@ Town::~Town()
for (const Industry *i : Industry::Iterate()) assert(i->town != this);
/* ... and no object is related to us. */
- const Object *o;
- FOR_ALL_OBJECTS(o) assert(o->town != this);
+ for (const Object *o : Object::Iterate()) assert(o->town != this);
/* Check no tile is related to us. */
for (TileIndex tile = 0; tile < MapSize(); ++tile) {
@@ -159,8 +158,7 @@ void Town::PostDestructor(size_t index)
UpdateNearestTownForRoadTiles(false);
/* Give objects a new home! */
- Object *o;
- FOR_ALL_OBJECTS(o) {
+ for (Object *o : Object::Iterate()) {
if (o->town == nullptr) o->town = CalcClosestTownFromTile(o->location.tile, UINT_MAX);
}
}