MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateAfterLoad

Method UpdateAfterLoad

src/group_cmd.cpp:120–145  ·  view source on GitHub ↗

* Update all caches after loading a game, changing NewGRF, etc. */ static */

Source from the content-addressed store, hash-verified

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.

Callers

nothing calls this directly

Calls 3

IsEngineCountableMethod · 0.80
ClearMethod · 0.45
IsPrimaryVehicleMethod · 0.45

Tested by

no test coverage detected