* 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. */
| 300 | * @param reset_cache Reset colourmap of vehicles in this group. |
| 301 | */ |
| 302 | static 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 |
no test coverage detected