* Set the livery for a vehicle group. * @param flags Command flags. * @param group_id Group ID. * @param primary Set primary instead of secondary colour * @param colour Colour. */
| 685 | * @param colour Colour. |
| 686 | */ |
| 687 | CommandCost CmdSetGroupLivery(DoCommandFlags flags, GroupID group_id, bool primary, Colours colour) |
| 688 | { |
| 689 | Group *g = Group::GetIfValid(group_id); |
| 690 | |
| 691 | if (g == nullptr || g->owner != _current_company) return CMD_ERROR; |
| 692 | |
| 693 | if (colour >= COLOUR_END && colour != INVALID_COLOUR) return CMD_ERROR; |
| 694 | |
| 695 | if (flags.Test(DoCommandFlag::Execute)) { |
| 696 | if (primary) { |
| 697 | g->livery.in_use.Set(Livery::Flag::Primary, colour != INVALID_COLOUR); |
| 698 | if (colour == INVALID_COLOUR) colour = GetParentLivery(g)->colour1; |
| 699 | g->livery.colour1 = colour; |
| 700 | } else { |
| 701 | g->livery.in_use.Set(Livery::Flag::Secondary, colour != INVALID_COLOUR); |
| 702 | if (colour == INVALID_COLOUR) colour = GetParentLivery(g)->colour2; |
| 703 | g->livery.colour2 = colour; |
| 704 | } |
| 705 | |
| 706 | PropagateChildLivery(g, true); |
| 707 | MarkWholeScreenDirty(); |
| 708 | } |
| 709 | |
| 710 | return CommandCost(); |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * Set group flag for a group and its sub-groups. |
nothing calls this directly
no test coverage detected