Codechange: Replace FOR_ALL_INDUSTRIES with range-based for loops

This commit is contained in:
glx
2019-12-16 18:51:20 +01:00
committed by Niels Martin Hansen
parent 4ae829cb27
commit 00c2a98cf3
11 changed files with 29 additions and 61 deletions

View File

@@ -745,9 +745,9 @@ static void Disaster_Airplane_Init()
{
if (!Vehicle::CanAllocateItem(2)) return;
Industry *i, *found = nullptr;
Industry *found = nullptr;
FOR_ALL_INDUSTRIES(i) {
for (Industry *i : Industry::Iterate()) {
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_AIRPLANE_ATTACKS) &&
(found == nullptr || Chance16(1, 2))) {
found = i;
@@ -771,9 +771,9 @@ static void Disaster_Helicopter_Init()
{
if (!Vehicle::CanAllocateItem(3)) return;
Industry *i, *found = nullptr;
Industry *found = nullptr;
FOR_ALL_INDUSTRIES(i) {
for (Industry *i : Industry::Iterate()) {
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CHOPPER_ATTACKS) &&
(found == nullptr || Chance16(1, 2))) {
found = i;
@@ -858,9 +858,7 @@ static void Disaster_CoalMine_Init()
uint m;
for (m = 0; m < 15; m++) {
const Industry *i;
FOR_ALL_INDUSTRIES(i) {
for (const Industry *i : Industry::Iterate()) {
if ((GetIndustrySpec(i->type)->behaviour & INDUSTRYBEH_CAN_SUBSIDENCE) && --index < 0) {
SetDParam(0, i->town->index);
AddTileNewsItem(STR_NEWS_DISASTER_COAL_MINE_SUBSIDENCE, NT_ACCIDENT, i->location.tile + TileDiffXY(1, 1)); // keep the news, even when the mine closes