OpenTTD Source: src/group_cmd.h File Reference

OpenTTD Source 14.1

Enumerations | Functions
group_cmd.h File Reference
`#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 | AlterGroupMode : byte { AlterGroupMode::Rename, AlterGroupMode::SetParent }
| Action for `CmdAlterGroup`. More...

## Functions
std::tuple< CommandCost, GroupID > | CmdCreateGroup (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, GroupID > | CmdAddVehicleGroup (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 : byte
| 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

  result | Did command succeed?
  new_group | ID of the created group.

Definition at line 1189 of file group_gui.cpp.

## ◆ CcCreateGroup()

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

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

Parameters

  result | Did command succeed?
  new_group | ID of the created group.
  vt | Vehicle type.

See also
  CmdCreateGroup

Definition at line 1176 of file group_gui.cpp.

## ◆ CmdAddSharedVehicleGroup()

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

Add all shared vehicles of all vehicles from a group.

Parameters

  flags | type of operation
  id_g | index of group
  type | type of vehicles

Returns
  the cost of this operation or an error

Definition at line 604 of file group_cmd.cpp.

References CMD_ERROR, DC_EXEC, Vehicle::FirstShared(), GetWindowClassForVehicleType(), InvalidateWindowData(), IsCompanyBuildableVehicleType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate(), and Vehicle::NextShared().

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

  flags | type of operation
  group_id | index of group
  veh_id | vehicle to add to a group
  add_shared | Add shared vehicles as well.

Returns
  the cost of this operation or an error

Definition at line 535 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
| ) |  |

Alter a group.

Parameters

  flags | type of operation
  mode | Operation to perform.
  group_id | GroupID
  parent_id | parent group index
  text | the new name or an empty string when resetting to the default

Returns
  the cost of this operation or an error

Definition at line 432 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(), GroupIsInGroup(), HasBit(), Livery::in_use, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_GROUP, Group::livery, MAX_LENGTH_GROUP_NAME_CHARS, Group::name, Group::owner, Group::parent, Rename, return_cmd_error, SetParent, GroupStatistics::UpdateAutoreplace(), Utf8StringLength(), and Group::vehicle_type.

## ◆ CmdCreateGroup()

std::tuple<CommandCost, GroupID> CmdCreateGroup | ( | DoCommandFlag | flags,
|  | VehicleType | vt,
|  | GroupID | parent_group
| ) |  |

Create a new vehicle group.

Parameters

  flags | type of operation
  vt | vehicle type
  parent_group | parent groupid

Returns
  the cost of this operation or an error

Definition at line 336 of file group_cmd.cpp.

References _current_company, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::CanAllocateItem(), CMD_ERROR, Livery::colour1, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), INVALID_GROUP, IsCompanyBuildableVehicleType(), Group::livery, Group::owner, Group::parent, and Group::vehicle_type.

## ◆ CmdDeleteGroup()

CommandCost CmdDeleteGroup | ( | DoCommandFlag | flags,
|  | GroupID | group_id
| ) |  |

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

Parameters

  flags | type of operation
  group_id | index of group

Returns
  the cost of this operation or an error

Definition at line 381 of file group_cmd.cpp.

References _current_company, OrderBackup::ClearGroup(), CloseWindowById(), CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), GetWindowClassForVehicleType(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_enginerenew_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Iterate(), MAX_COMPANIES, Group::owner, RemoveEngineReplacementForCompany(), Group::vehicle_type, and WC_REPLACE_VEHICLE.

## ◆ CmdRemoveAllVehiclesGroup()

CommandCost CmdRemoveAllVehiclesGroup | ( | DoCommandFlag | flags,
|  | GroupID | group_id
| ) |  |

Remove all vehicles from a group.

Parameters

  flags | type of operation
  group_id | index of group

Returns
  the cost of this operation or an error

Definition at line 635 of file group_cmd.cpp.

References _current_company, CMD_ERROR, DC_EXEC, DEFAULT_GROUP, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), GetWindowClassForVehicleType(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate(), Group::owner, and Group::vehicle_type.

## ◆ CmdSetGroupFlag()

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

(Un)set group flag from a group

Parameters

  flags | type of operation
  group_id | index of group array
  flag | flag to set, by value not bit.
  value | value to set the flag to.
  recursive | to apply to sub-groups.

Returns
  the cost of this operation or an error

Definition at line 720 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

  flags | Command flags.
  group_id | Group ID.
  primary | Set primary instead of secondary colour
  colour | Colour.

Definition at line 665 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.