summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-16 18:51:20 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commit00c2a98cf395d6e2a85290048e7be7a7f6ce0d04 (patch)
tree78cc73b1290a8076f3a1b7d6bbfad9aef1acba8d /src/industry_cmd.cpp
parent4ae829cb272225c7e07e233a94c2d945077f432a (diff)
downloadopenttd-00c2a98cf395d6e2a85290048e7be7a7f6ce0d04.tar.xz
Codechange: Replace FOR_ALL_INDUSTRIES with range-based for loops
Diffstat (limited to 'src/industry_cmd.cpp')
-rw-r--r--src/industry_cmd.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index b1c97b752..3bbd22bd0 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1203,8 +1203,7 @@ void OnTick_Industry()
if (_game_mode == GM_EDITOR) return;
- Industry *i;
- FOR_ALL_INDUSTRIES(i) {
+ for (Industry *i : Industry::Iterate()) {
ProduceIndustryGoods(i);
}
}
@@ -1391,8 +1390,7 @@ static CommandCost FindTownForIndustry(TileIndex tile, int type, Town **t)
if (_settings_game.economy.multiple_industry_per_town) return CommandCost();
- const Industry *i;
- FOR_ALL_INDUSTRIES(i) {
+ for (const Industry *i : Industry::Iterate()) {
if (i->type == (byte)type && i->town == *t) {
*t = nullptr;
return_cmd_error(STR_ERROR_ONLY_ONE_ALLOWED_PER_TOWN);
@@ -1629,11 +1627,11 @@ static bool CheckIfCanLevelIndustryPlatform(TileIndex tile, DoCommandFlag flags,
static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int type)
{
const IndustrySpec *indspec = GetIndustrySpec(type);
- const Industry *i = nullptr;
/* On a large map with many industries, it may be faster to check an area. */
static const int dmax = 14;
if (Industry::GetNumItems() > (size_t) (dmax * dmax * 2)) {
+ const Industry* i = nullptr;
TileArea tile_area = TileArea(tile, 1, 1).Expand(dmax);
TILE_AREA_LOOP(atile, tile_area) {
if (GetTileType(atile) == MP_INDUSTRY) {
@@ -1651,7 +1649,7 @@ static CommandCost CheckIfFarEnoughFromConflictingIndustry(TileIndex tile, int t
return CommandCost();
}
- FOR_ALL_INDUSTRIES(i) {
+ for (const Industry *i : Industry::Iterate()) {
/* Within 14 tiles from another industry is considered close */
if (DistanceMax(tile, i->location.tile) > 14) continue;
@@ -2833,8 +2831,7 @@ void IndustryMonthlyLoop()
_industry_builder.MonthlyLoop();
- Industry *i;
- FOR_ALL_INDUSTRIES(i) {
+ for (Industry *i : Industry::Iterate()) {
UpdateIndustryStatistics(i);
if (i->prod_level == PRODLEVEL_CLOSURE) {
delete i;