From 38c97e14926f4bc538c20b24f8a3decdef1668f9 Mon Sep 17 00:00:00 2001 From: glx22 Date: Wed, 12 May 2021 16:45:28 +0200 Subject: Codechange: Replace TILE_AREA_LOOP with range-based for loops --- src/script/api/script_industry.cpp | 4 ++-- src/script/api/script_order.cpp | 8 ++++---- src/script/api/script_tilelist.cpp | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/script') diff --git a/src/script/api/script_industry.cpp b/src/script/api/script_industry.cpp index 0a5ca98d3..6f54fda14 100644 --- a/src/script/api/script_industry.cpp +++ b/src/script/api/script_industry.cpp @@ -186,7 +186,7 @@ if (!HasHeliport(industry_id)) return INVALID_TILE; const Industry *ind = ::Industry::Get(industry_id); - TILE_AREA_LOOP(tile_cur, ind->location) { + for (TileIndex tile_cur : ind->location) { if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) { return tile_cur; } @@ -208,7 +208,7 @@ if (!HasDock(industry_id)) return INVALID_TILE; const Industry *ind = ::Industry::Get(industry_id); - TILE_AREA_LOOP(tile_cur, ind->location) { + for (TileIndex tile_cur : ind->location) { if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) { return tile_cur; } diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index 5166c0614..b7bcde730 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -256,11 +256,11 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr case OT_GOTO_STATION: { const Station *st = ::Station::Get(order->GetDestination()); if (st->train_station.tile != INVALID_TILE) { - TILE_AREA_LOOP(t, st->train_station) { + for (TileIndex t : st->train_station) { if (st->TileBelongsToRailStation(t)) return t; } } else if (st->ship_station.tile != INVALID_TILE) { - TILE_AREA_LOOP(t, st->ship_station) { + for (TileIndex t : st->ship_station) { if (IsTileType(t, MP_STATION) && (IsDock(t) || IsOilRig(t)) && GetStationIndex(t) == st->index) return t; } } else if (st->bus_stops != nullptr) { @@ -268,7 +268,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr } else if (st->truck_stops != nullptr) { return st->truck_stops->xy; } else if (st->airport.tile != INVALID_TILE) { - TILE_AREA_LOOP(tile, st->airport) { + for (TileIndex tile : st->airport) { if (st->TileBelongsToAirport(tile) && !::IsHangar(tile)) return tile; } } @@ -278,7 +278,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr case OT_GOTO_WAYPOINT: { const Waypoint *wp = ::Waypoint::Get(order->GetDestination()); if (wp->train_station.tile != INVALID_TILE) { - TILE_AREA_LOOP(t, wp->train_station) { + for (TileIndex t : wp->train_station) { if (wp->TileBelongsToRailStation(t)) return t; } } diff --git a/src/script/api/script_tilelist.cpp b/src/script/api/script_tilelist.cpp index 7f4e3ca5c..8266f46ff 100644 --- a/src/script/api/script_tilelist.cpp +++ b/src/script/api/script_tilelist.cpp @@ -21,7 +21,7 @@ void ScriptTileList::AddRectangle(TileIndex t1, TileIndex t2) if (!::IsValidTile(t2)) return; TileArea ta(t1, t2); - TILE_AREA_LOOP(t, ta) this->AddItem(t); + for (TileIndex t : ta) this->AddItem(t); } void ScriptTileList::AddTile(TileIndex tile) @@ -37,7 +37,7 @@ void ScriptTileList::RemoveRectangle(TileIndex t1, TileIndex t2) if (!::IsValidTile(t2)) return; TileArea ta(t1, t2); - TILE_AREA_LOOP(t, ta) this->RemoveItem(t); + for (TileIndex t : ta) this->RemoveItem(t); } void ScriptTileList::RemoveTile(TileIndex tile) @@ -55,7 +55,7 @@ void ScriptTileList::RemoveTile(TileIndex tile) */ static void FillIndustryCatchment(const Industry *i, int radius, BitmapTileArea &bta) { - TILE_AREA_LOOP(cur_tile, i->location) { + for (TileIndex cur_tile : i->location) { if (!::IsTileType(cur_tile, MP_INDUSTRY) || ::GetIndustryIndex(cur_tile) != i->index) continue; int tx = TileX(cur_tile); @@ -156,7 +156,7 @@ ScriptTileList_StationType::ScriptTileList_StationType(StationID station_id, Scr if ((station_type & ScriptStation::STATION_DOCK) != 0) station_type_value |= (1 << ::STATION_DOCK) | (1 << ::STATION_OILRIG); TileArea ta(::TileXY(rect->left, rect->top), rect->right - rect->left + 1, rect->bottom - rect->top + 1); - TILE_AREA_LOOP(cur_tile, ta) { + for (TileIndex cur_tile : ta) { if (!::IsTileType(cur_tile, MP_STATION)) continue; if (::GetStationIndex(cur_tile) != station_id) continue; if (!HasBit(station_type_value, ::GetStationType(cur_tile))) continue; -- cgit v1.2.3-70-g09d2