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

Function UpdateNumEngineGroup

src/group_cmd.cpp:273–282  ·  view source on GitHub ↗

* Update the num engines of a groupID. Decrease the old one and increase the new one * @note called in SetTrainGroupID and UpdateTrainGroupID * @param v Vehicle we have to update * @param old_g index of the old group * @param new_g index of the new group */

Source from the content-addressed store, hash-verified

271 * @param new_g index of the new group
272 */
273static inline void UpdateNumEngineGroup(const Vehicle *v, GroupID old_g, GroupID new_g)
274{
275 if (old_g != new_g) {
276 /* Decrease the num engines in the old group */
277 GroupStatistics::Get(v->owner, old_g, v->type).num_engines[v->engine_type]--;
278
279 /* Increase the num engines in the new group */
280 GroupStatistics::Get(v->owner, new_g, v->type).num_engines[v->engine_type]++;
281 }
282}
283
284
285const Livery *GetParentLivery(const Group *g)

Callers 3

AddVehicleToGroupFunction · 0.85
SetTrainGroupIDFunction · 0.85
UpdateTrainGroupIDFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected