OpenTTD Source 20241224-master-gf74b0cf984
group_cmd.h File Reference

Command definitions related to engine groups. More...

#include "command_type.h"
#include "group_type.h"
#include "vehicle_type.h"
#include "vehiclelist.h"
#include "vehiclelist_cmd.h"

Go to the source code of this file.

Enumerations

enum class  AlterGroupMode : uint8_t { Rename , SetParent }
 Action for CmdAlterGroup. More...
 

Functions

std::tuple< CommandCost, GroupIDCmdCreateGroup (DoCommandFlag flags, VehicleType vt, GroupID parent_group)
 Create a new vehicle group.
 
CommandCost CmdAlterGroup (DoCommandFlag flags, AlterGroupMode mode, GroupID group_id, GroupID parent_id, const std::string &text)
 Alter a group.
 
CommandCost CmdDeleteGroup (DoCommandFlag flags, GroupID group_id)
 Add all vehicles in the given group to the default group and then deletes the group.
 
std::tuple< CommandCost, GroupIDCmdAddVehicleGroup (DoCommandFlag flags, GroupID group_id, VehicleID veh_id, bool add_shared, const VehicleListIdentifier &vli)
 Add a vehicle to a group.
 
CommandCost CmdAddSharedVehicleGroup (DoCommandFlag flags, GroupID id_g, VehicleType type)
 Add all shared vehicles of all vehicles from a group.
 
CommandCost CmdRemoveAllVehiclesGroup (DoCommandFlag flags, GroupID group_id)
 Remove all vehicles from a group.
 
CommandCost CmdSetGroupFlag (DoCommandFlag flags, GroupID group_id, GroupFlags flag, bool value, bool recursive)
 (Un)set group flag from a group
 
CommandCost CmdSetGroupLivery (DoCommandFlag flags, GroupID group_id, bool primary, Colours colour)
 Set the livery for a vehicle group.
 
void CcCreateGroup (Commands cmd, const CommandCost &result, GroupID new_group, VehicleType vt, GroupID parent_group)
 Opens a 'Rename group' window for newly created group.
 
void CcAddVehicleNewGroup (Commands cmd, const CommandCost &result, GroupID new_group, GroupID, VehicleID veh_id, bool, const VehicleListIdentifier &)
 Open rename window after adding a vehicle to a new group via drag and drop.
 

Detailed Description

Command definitions related to engine groups.

Definition in file group_cmd.h.

Enumeration Type Documentation

◆ AlterGroupMode

enum class AlterGroupMode : uint8_t
strong

Action for CmdAlterGroup.

Enumerator
Rename 

Change group name.

SetParent 

Change group parent.

Definition at line 23 of file group_cmd.h.

Function Documentation

◆ CcAddVehicleNewGroup()

void CcAddVehicleNewGroup ( Commands  cmd,
const CommandCost result,
GroupID  new_group,
GroupID  ,
VehicleID  veh_id,
bool  ,
const VehicleListIdentifier  
)

Open rename window after adding a vehicle to a new group via drag and drop.

Parameters
resultDid command succeed?
new_groupID of the created group.

Definition at line 1240 of file group_gui.cpp.

References CcCreateGroup(), CommandCost::Failed(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Get(), and Group::vehicle_type.

Referenced by VehicleGroupWindow::OnDropdownSelect(), and VehicleListWindow::OnDropdownSelect().

◆ CcCreateGroup()

void CcCreateGroup ( Commands  cmd,
const CommandCost result,
GroupID  new_group,
VehicleType  vt,
GroupID  parent_group 
)

Opens a 'Rename group' window for newly created group.

Parameters
resultDid command succeed?
new_groupID of the created group.
vtVehicle type.
See also
CmdCreateGroup

Definition at line 1227 of file group_gui.cpp.

References CcCreateGroup(), CommandCost::Failed(), and VEH_AIRCRAFT.

◆ CmdAddSharedVehicleGroup()

CommandCost CmdAddSharedVehicleGroup ( DoCommandFlag  flags,
GroupID  id_g,
VehicleType  type 
)

◆ CmdAddVehicleGroup()

◆ CmdAlterGroup()

◆ CmdCreateGroup()

◆ CmdDeleteGroup()

◆ CmdRemoveAllVehiclesGroup()

◆ CmdSetGroupFlag()

CommandCost CmdSetGroupFlag ( DoCommandFlag  flags,
GroupID  group_id,
GroupFlags  flag,
bool  value,
bool  recursive 
)

(Un)set group flag from a group

Parameters
flagstype of operation
group_idindex of group array
flagflag to set, by value not bit.
valuevalue to set the flag to.
recursiveto apply to sub-groups.
Returns
the cost of this operation or an error

Definition at line 722 of file group_cmd.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), GetWindowClassForVehicleType(), InvalidateWindowData(), Group::owner, VehicleListIdentifier::Pack(), SetGroupFlag(), SetWindowDirty(), Group::vehicle_type, and WC_REPLACE_VEHICLE.

◆ CmdSetGroupLivery()

CommandCost CmdSetGroupLivery ( DoCommandFlag  flags,
GroupID  group_id,
bool  primary,
Colours  colour 
)

Set the livery for a vehicle group.

Parameters
flagsCommand flags.
group_idGroup ID.
primarySet primary instead of secondary colour
colourColour.

Definition at line 667 of file group_cmd.cpp.

References _current_company, AssignBit(), CMD_ERROR, Livery::colour1, Livery::colour2, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), Livery::in_use, Group::livery, MarkWholeScreenDirty(), Group::owner, and PropagateChildLivery().