* Update all caches after loading a game, changing NewGRF, etc. */ static */
| 118 | * Update all caches after loading a game, changing NewGRF, etc. |
| 119 | */ |
| 120 | /* static */ void GroupStatistics::UpdateAfterLoad() |
| 121 | { |
| 122 | /* Set up the engine count for all companies */ |
| 123 | for (Company *c : Company::Iterate()) { |
| 124 | for (VehicleType type = VEH_BEGIN; type < VEH_COMPANY_END; type++) { |
| 125 | c->group_all[type].Clear(); |
| 126 | c->group_default[type].Clear(); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /* Recalculate */ |
| 131 | for (Group *g : Group::Iterate()) { |
| 132 | g->statistics.Clear(); |
| 133 | } |
| 134 | |
| 135 | for (const Vehicle *v : Vehicle::Iterate()) { |
| 136 | if (!v->IsEngineCountable()) continue; |
| 137 | |
| 138 | GroupStatistics::CountEngine(v, 1); |
| 139 | if (v->IsPrimaryVehicle()) GroupStatistics::CountVehicle(v, 1); |
| 140 | } |
| 141 | |
| 142 | for (const Company *c : Company::Iterate()) { |
| 143 | GroupStatistics::UpdateAutoreplace(c->index); |
| 144 | } |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Update num_vehicle when adding or removing a vehicle. |
nothing calls this directly
no test coverage detected