mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Iterate group vehicle lists for GroupStatistics::UpdateProfits
parent
89c69f991c
commit
4ee690b911
|
@ -204,23 +204,21 @@ void GroupStatistics::Clear()
|
||||||
*/
|
*/
|
||||||
/* static */ void GroupStatistics::UpdateProfits()
|
/* static */ void GroupStatistics::UpdateProfits()
|
||||||
{
|
{
|
||||||
/* Set up the engine count for all companies */
|
|
||||||
for (Company *c : Company::Iterate()) {
|
|
||||||
for (VehicleType type = VEH_BEGIN; type < VEH_COMPANY_END; type++) {
|
|
||||||
c->group_all[type].ClearProfits();
|
|
||||||
c->group_default[type].ClearProfits();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Recalculate */
|
|
||||||
for (Group *g : Group::Iterate()) {
|
for (Group *g : Group::Iterate()) {
|
||||||
g->statistics.ClearProfits();
|
g->statistics.ClearProfits();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const Vehicle *v : Vehicle::Iterate()) {
|
for (Company *c : Company::Iterate()) {
|
||||||
if (v->IsPrimaryVehicle()) {
|
for (VehicleType type = VEH_BEGIN; type < VEH_COMPANY_END; type++) {
|
||||||
GroupStatistics::AddProfitLastYear(v);
|
c->group_all[type].ClearProfits();
|
||||||
if (v->age > VEHICLE_PROFIT_MIN_AGE) GroupStatistics::VehicleReachedMinAge(v);
|
c->group_default[type].ClearProfits();
|
||||||
|
|
||||||
|
/* Recalculate */
|
||||||
|
const VehicleList &vehicle_list = c->group_all[type].vehicle_list;
|
||||||
|
for (const Vehicle *v : vehicle_list) {
|
||||||
|
GroupStatistics::AddProfitLastYear(v);
|
||||||
|
if (v->age > VEHICLE_PROFIT_MIN_AGE) GroupStatistics::VehicleReachedMinAge(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue