OpenTTD Source  20241108-master-g80f628063a
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. More...
 
CommandCost CmdAlterGroup (DoCommandFlag flags, AlterGroupMode mode, GroupID group_id, GroupID parent_id, const std::string &text)
 Alter a group. More...
 
CommandCost CmdDeleteGroup (DoCommandFlag flags, GroupID group_id)
 Add all vehicles in the given group to the default group and then deletes the group. More...
 
std::tuple< CommandCost, GroupIDCmdAddVehicleGroup (DoCommandFlag flags, GroupID group_id, VehicleID veh_id, bool add_shared, const VehicleListIdentifier &vli)
 Add a vehicle to a group. More...
 
CommandCost CmdAddSharedVehicleGroup (DoCommandFlag flags, GroupID id_g, VehicleType type)
 Add all shared vehicles of all vehicles from a group. More...
 
CommandCost CmdRemoveAllVehiclesGroup (DoCommandFlag flags, GroupID group_id)
 Remove all vehicles from a group. More...
 
CommandCost CmdSetGroupFlag (DoCommandFlag flags, GroupID group_id, GroupFlags flag, bool value, bool recursive)
 (Un)set group flag from a group More...
 
CommandCost CmdSetGroupLivery (DoCommandFlag flags, GroupID group_id, bool primary, Colours colour)
 Set the livery for a vehicle group. More...
 
void CcCreateGroup (Commands cmd, const CommandCost &result, GroupID new_group, VehicleType vt, GroupID parent_group)
 Opens a 'Rename group' window for newly created group. More...
 
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. More...
 

Detailed Description

Command definitions related to engine groups.

Definition in file group_cmd.h.

Enumeration Type Documentation

◆ AlterGroupMode

enum 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.

◆ 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.

◆ CmdAddSharedVehicleGroup()

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

◆ CmdAddVehicleGroup()

std::tuple<CommandCost, GroupID> CmdAddVehicleGroup ( DoCommandFlag  flags,
GroupID  group_id,
VehicleID  veh_id,
bool  add_shared,
const VehicleListIdentifier vli 
)

Add a vehicle to a group.

Parameters
flagstype of operation
group_idindex of group
veh_idvehicle to add to a group
add_sharedAdd shared vehicles as well.
Returns
the cost of this operation or an error

Definition at line 537 of file group_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID().

◆ CmdAlterGroup()

CommandCost CmdAlterGroup ( DoCommandFlag  flags,
AlterGroupMode  mode,
GroupID  group_id,
GroupID  parent_id,
const std::string &  text 
)

◆ 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, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), and Group::owner.

◆ 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, CMD_ERROR, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), and Group::owner.