Codechange: Replace vehicle related FOR_ALL with range-based for loops

This commit is contained in:
glx
2019-12-17 03:37:43 +01:00
committed by Niels Martin Hansen
parent 9892d90b26
commit d8a1be48cd
39 changed files with 155 additions and 317 deletions

View File

@@ -120,8 +120,7 @@ Money CalculateCompanyValue(const Company *c, bool including_loan)
Money value = num * _price[PR_STATION_VALUE] * 25;
Vehicle *v;
FOR_ALL_VEHICLES(v) {
for (const Vehicle *v : Vehicle::Iterate()) {
if (v->owner != owner) continue;
if (v->type == VEH_TRAIN ||
@@ -156,12 +155,11 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
/* Count vehicles */
{
Vehicle *v;
Money min_profit = 0;
bool min_profit_first = true;
uint num = 0;
FOR_ALL_VEHICLES(v) {
for (const Vehicle *v : Vehicle::Iterate()) {
if (v->owner != owner) continue;
if (IsCompanyBuildableVehicleType(v->type) && v->IsPrimaryVehicle()) {
if (v->profit_last_year > 0) num++; // For the vehicle score only count profitable vehicles
@@ -390,8 +388,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
}
{
Vehicle *v;
FOR_ALL_VEHICLES(v) {
for (Vehicle *v : Vehicle::Iterate()) {
if (v->owner == old_owner && IsCompanyBuildableVehicleType(v->type)) {
if (new_owner == INVALID_OWNER) {
if (v->Previous() == nullptr) delete v;
@@ -435,8 +432,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
old_company->settings.vehicle.servint_ispercent = new_company->settings.vehicle.servint_ispercent;
}
Vehicle *v;
FOR_ALL_VEHICLES(v) {
for (Vehicle *v : Vehicle::Iterate()) {
if (v->owner == old_owner && IsCompanyBuildableVehicleType(v->type)) {
assert(new_owner != INVALID_OWNER);