diff options
author | glx <glx@openttd.org> | 2019-12-14 17:22:38 +0100 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-12-21 20:13:03 +0100 |
commit | 3a14cea068d130e11b5d9dde11d4451dd7dec453 (patch) | |
tree | 7afd5a1160872aeba8a630c2915a8168cbc483dd /src/engine.cpp | |
parent | 68f22134cb35267d6fa01134a385d3854fda1787 (diff) | |
download | openttd-3a14cea068d130e11b5d9dde11d4451dd7dec453.tar.xz |
Codechange: Replace FOR_ALL_COMPANIES with range-based for loops
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 3027ee387..4baf906e5 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -703,8 +703,7 @@ void StartupEngines() } /* Update the bitmasks for the vehicle lists */ - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->avail_railtypes = GetCompanyRailtypes(c->index); c->avail_roadtypes = GetCompanyRoadTypes(c->index); } @@ -763,8 +762,7 @@ static CompanyID GetPreviewCompany(Engine *e) CargoTypes cargomask = e->type != VEH_TRAIN ? GetUnionOfArticulatedRefitMasks(e->index, true) : ALL_CARGOTYPES; int32 best_hist = -1; - const Company *c; - FOR_ALL_COMPANIES(c) { + for (const Company *c : Company::Iterate()) { if (c->block_preview == 0 && !HasBit(e->preview_asked, c->index) && c->old_economy[0].performance_history > best_hist) { @@ -806,8 +804,7 @@ static bool IsVehicleTypeDisabled(VehicleType type, bool ai) /** Daily check to offer an exclusive engine preview to the companies. */ void EnginesDailyLoop() { - Company *c; - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes, _date); c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes, _date); } @@ -908,13 +905,12 @@ CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, static void NewVehicleAvailable(Engine *e) { Vehicle *v; - Company *c; EngineID index = e->index; /* In case the company didn't build the vehicle during the intro period, * prevent that company from getting future intro periods for a while. */ if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) { - FOR_ALL_COMPANIES(c) { + for (Company *c : Company::Iterate()) { uint block_preview = c->block_preview; if (!HasBit(e->company_avail, c->index)) continue; @@ -948,11 +944,11 @@ static void NewVehicleAvailable(Engine *e) /* maybe make another rail type available */ RailType railtype = e->u.rail.railtype; assert(railtype < RAILTYPE_END); - FOR_ALL_COMPANIES(c) c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes | GetRailTypeInfo(e->u.rail.railtype)->introduces_railtypes, _date); + for (Company *c : Company::Iterate()) c->avail_railtypes = AddDateIntroducedRailTypes(c->avail_railtypes | GetRailTypeInfo(e->u.rail.railtype)->introduces_railtypes, _date); } else if (e->type == VEH_ROAD) { /* maybe make another road type available */ assert(e->u.road.roadtype < ROADTYPE_END); - FOR_ALL_COMPANIES(c) c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes | GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes, _date); + for (Company* c : Company::Iterate()) c->avail_roadtypes = AddDateIntroducedRoadTypes(c->avail_roadtypes | GetRoadTypeInfo(e->u.road.roadtype)->introduces_roadtypes, _date); } /* Only broadcast event if AIs are able to build this vehicle type. */ |