summaryrefslogtreecommitdiff
path: root/src/group_cmd.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/group_cmd.cpp
parent9892d90b26db4dfe97ec7baeb89e43acb53a178e (diff)
downloadopenttd-d8a1be48cd60c690235de175e9a044b95f92ea28.tar.xz
Codechange: Replace vehicle related FOR_ALL with range-based for loops
Diffstat (limited to 'src/group_cmd.cpp')
-rw-r--r--src/group_cmd.cpp17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp
index a13cd5f38..497d74d68 100644
--- a/src/group_cmd.cpp
+++ b/src/group_cmd.cpp
@@ -113,8 +113,7 @@ void GroupStatistics::Clear()
g->statistics.Clear();
}
- const Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (!v->IsEngineCountable()) continue;
GroupStatistics::CountEngine(v, 1);
@@ -193,8 +192,7 @@ void GroupStatistics::Clear()
g->statistics.ClearProfits();
}
- const Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (v->IsPrimaryVehicle() && v->age > VEHICLE_PROFIT_MIN_AGE) GroupStatistics::VehicleReachedProfitAge(v);
}
}
@@ -267,8 +265,7 @@ const Livery *GetParentLivery(const Group *g)
void PropagateChildLivery(const Group *g)
{
/* Company colour data is indirectly cached. */
- Vehicle *v;
- FOR_ALL_VEHICLES(v) {
+ for (Vehicle *v : Vehicle::Iterate()) {
if (v->group_id == g->index && (!v->IsGroundVehicle() || v->IsFrontEngine())) {
for (Vehicle *u = v; u != nullptr; u = u->Next()) {
u->colourmap = PAL_NONE;
@@ -573,11 +570,9 @@ CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32
if (!Group::IsValidID(id_g) || !IsCompanyBuildableVehicleType(type)) return CMD_ERROR;
if (flags & DC_EXEC) {
- Vehicle *v;
-
/* Find the first front engine which belong to the group id_g
* then add all shared vehicles of this front engine to the group id_g */
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (v->type == type && v->IsPrimaryVehicle()) {
if (v->group_id != id_g) continue;
@@ -613,10 +608,8 @@ CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint3
if (g == nullptr || g->owner != _current_company) return CMD_ERROR;
if (flags & DC_EXEC) {
- Vehicle *v;
-
/* Find each Vehicle that belongs to the group old_g and add it to the default group */
- FOR_ALL_VEHICLES(v) {
+ for (const Vehicle *v : Vehicle::Iterate()) {
if (v->IsPrimaryVehicle()) {
if (v->group_id != old_g) continue;