summaryrefslogtreecommitdiff
path: root/src/industry_cmd.cpp
diff options
context:
space:
mode:
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;