From 7d0b1cd002c49db1007ac6c47e808dcfac835f1a Mon Sep 17 00:00:00 2001 From: SamuXarick <43006711+SamuXarick@users.noreply.github.com> Date: Sun, 27 Oct 2024 19:49:34 +0000 Subject: [PATCH] Codechange: Replace while loop with Map::Iterate() --- src/economy.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/economy.cpp b/src/economy.cpp index d72056fc56..d71940e5cc 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -489,19 +489,16 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) /* Change ownership of tiles */ { - TileIndex tile = 0; - do { + for (const auto tile : Map::Iterate()) { ChangeTileOwner(tile, old_owner, new_owner); - } while (++tile != Map::Size()); + } if (new_owner != INVALID_OWNER) { /* Update all signals because there can be new segment that was owned by two companies * and signals were not propagated * Similar with crossings - it is needed to bar crossings that weren't before * because of different owner of crossing and approaching train */ - tile = 0; - - do { + for (const auto tile : Map::Iterate()) { if (IsTileType(tile, MP_RAILWAY) && IsTileOwner(tile, new_owner) && HasSignals(tile)) { TrackBits tracks = GetTrackBits(tile); do { // there may be two tracks with signals for TRACK_BIT_HORZ and TRACK_BIT_VERT @@ -511,7 +508,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner) } else if (IsLevelCrossingTile(tile) && IsTileOwner(tile, new_owner)) { UpdateLevelCrossing(tile); } - } while (++tile != Map::Size()); + } } /* update signals in buffer */