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

Function PropagateChildLivery

src/group_cmd.cpp:302–322  ·  view source on GitHub ↗

* Propagate a livery change to a group's children, and optionally update cached vehicle colourmaps. * @param g Group to propagate colours to children. * @param reset_cache Reset colourmap of vehicles in this group. */

Source from the content-addressed store, hash-verified

300 * @param reset_cache Reset colourmap of vehicles in this group.
301 */
302static void PropagateChildLivery(const Group *g, bool reset_cache)
303{
304 if (reset_cache) {
305 /* Company colour data is indirectly cached. */
306 for (Vehicle *v : Vehicle::Iterate()) {
307 if (v->group_id == g->index && (!v->IsGroundVehicle() || v->IsFrontEngine())) {
308 for (Vehicle *u = v; u != nullptr; u = u->Next()) {
309 u->colourmap = PAL_NONE;
310 u->InvalidateNewGRFCache();
311 }
312 }
313 }
314 }
315
316 for (const GroupID &childgroup : g->children) {
317 Group *cg = Group::Get(childgroup);
318 if (!cg->livery.in_use.Test(Livery::Flag::Primary)) cg->livery.colour1 = g->livery.colour1;
319 if (!cg->livery.in_use.Test(Livery::Flag::Secondary)) cg->livery.colour2 = g->livery.colour2;
320 PropagateChildLivery(cg, reset_cache);
321 }
322}
323
324/**
325 * Update group liveries for a company. This is called when the LS_DEFAULT scheme is changed, to update groups with

Callers 3

CmdAlterGroupFunction · 0.85
CmdSetGroupLiveryFunction · 0.85

Calls 5

IsFrontEngineMethod · 0.80
InvalidateNewGRFCacheMethod · 0.80
TestMethod · 0.80
IsGroundVehicleMethod · 0.45
NextMethod · 0.45

Tested by

no test coverage detected