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

References CcCreateGroup(), CommandCost::Failed(), and Group::vehicle_type.

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

◆ CcCreateGroup()

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

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 1284 of file group_gui.cpp.

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

◆ CmdAddSharedVehicleGroup()

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

Add all shared vehicles of all vehicles from a group.

Parameters
flagstype of operation
id_gindex of group
typetype of vehicles
Returns
the cost of this operation or an error

Definition at line 627 of file group_cmd.cpp.

References _current_company, CMD_ERROR, Execute, Vehicle::FirstShared(), GetWindowClassForVehicleType(), InvalidateWindowData(), IsCompanyBuildableVehicleType(), Vehicle::NextShared(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and VL_GROUP_LIST.

◆ CmdAddVehicleGroup()

std::tuple< CommandCost, GroupID > CmdAddVehicleGroup ( DoCommandFlags 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.
vliThe list of vehicles that should be added to the group (can be empty).
Returns
the cost of this operation or an error

Definition at line 562 of file group_cmd.cpp.

References _current_company, AddVehicleToGroup(), CMD_ERROR, CmdCreateGroup(), Execute, Vehicle::FirstShared(), GenerateVehicleSortList(), GetWindowClassForVehicleType(), InvalidateWindowData(), NEW_GROUP, Vehicle::NextShared(), Group::owner, SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Vehicle::tile, GroupStatistics::UpdateAutoreplace(), Group::vehicle_type, VL_GROUP_LIST, WC_REPLACE_VEHICLE, and WC_VEHICLE_DEPOT.

◆ CmdAlterGroup()

◆ CmdCreateGroup()

◆ CmdDeleteGroup()

CommandCost CmdDeleteGroup ( DoCommandFlags flags,
GroupID group_id )

Add all vehicles in the given group to the default group and then deletes the group.

Parameters
flagstype of operation
group_idindex of group
Returns
the cost of this operation or an error

Definition at line 393 of file group_cmd.cpp.

References _current_company, Group::children, OrderBackup::ClearGroup(), CloseWindowById(), CMD_ERROR, Execute, GetWindowClassForVehicleType(), InvalidateWindowData(), Group::number, Group::owner, Group::parent, FreeUnitIDGenerator::ReleaseID(), RemoveEngineReplacementForCompany(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Group::vehicle_type, VL_GROUP_LIST, WC_COMPANY_COLOUR, and WC_REPLACE_VEHICLE.

◆ CmdRemoveAllVehiclesGroup()

CommandCost CmdRemoveAllVehiclesGroup ( DoCommandFlags flags,
GroupID group_id )

Remove all vehicles from a group.

Parameters
flagstype of operation
group_idindex of group
Returns
the cost of this operation or an error

Definition at line 658 of file group_cmd.cpp.

References _current_company, CMD_ERROR, DEFAULT_GROUP, Execute, GetWindowClassForVehicleType(), InvalidateWindowData(), Group::owner, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), VehicleListIdentifier::ToWindowNumber(), Group::vehicle_type, and VL_GROUP_LIST.

◆ CmdSetGroupFlag()

CommandCost CmdSetGroupFlag ( DoCommandFlags flags,
GroupID group_id,
GroupFlag 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 745 of file group_cmd.cpp.

References _current_company, CMD_ERROR, Execute, GetWindowClassForVehicleType(), InvalidateWindowData(), Group::owner, ReplaceProtection, ReplaceWagonRemoval, SetGroupFlag(), SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), VehicleListIdentifier::ToWindowNumber(), Group::vehicle_type, VL_GROUP_LIST, and WC_REPLACE_VEHICLE.

◆ CmdSetGroupLivery()

CommandCost CmdSetGroupLivery ( DoCommandFlags 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 688 of file group_cmd.cpp.

References _current_company, CMD_ERROR, Livery::colour1, Livery::colour2, Execute, Livery::in_use, Group::livery, MarkWholeScreenDirty(), Group::owner, Livery::Primary, PropagateChildLivery(), Livery::Secondary, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().