summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-12-17 03:37:43 +0100
committerNiels Martin Hansen <nielsm@indvikleren.dk>2019-12-21 20:13:03 +0100
commitd8a1be48cd60c690235de175e9a044b95f92ea28 (patch)
tree2e1481aa11661c28df49f0d62f56fbf730577152 /src/engine.cpp
parent9892d90b26db4dfe97ec7baeb89e43acb53a178e (diff)
downloadopenttd-d8a1be48cd60c690235de175e9a044b95f92ea28.tar.xz
Codechange: Replace vehicle related FOR_ALL with range-based for loops
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index d0333b8f4..66e68fd3c 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -526,8 +526,7 @@ EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uin
*/
bool EngineOverrideManager::ResetToCurrentNewGRFConfig()
{
- const Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (IsCompanyBuildableVehicleType(v)) return false;
}
@@ -765,8 +764,7 @@ static CompanyID GetPreviewCompany(Engine *e)
c->old_economy[0].performance_history > best_hist) {
/* Check whether the company uses similar vehicles */
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (v->owner != c->index || v->type != e->type) continue;
if (!v->GetEngine()->CanCarryCargo() || !HasBit(cargomask, v->cargo_type)) continue;
@@ -900,7 +898,6 @@ CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1,
*/
static void NewVehicleAvailable(Engine *e)
{
- Vehicle *v;
EngineID index = e->index;
/* In case the company didn't build the vehicle during the intro period,
@@ -914,7 +911,7 @@ static void NewVehicleAvailable(Engine *e)
/* We assume the user did NOT build it.. prove me wrong ;) */
c->block_preview = 20;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (v->type == VEH_TRAIN || v->type == VEH_ROAD || v->type == VEH_SHIP ||
(v->type == VEH_AIRCRAFT && Aircraft::From(v)->IsNormalAircraft())) {
if (v->owner == c->index && v->engine_type == index) {