OpenTTD Source: src/company_cmd.h File Reference

OpenTTD Source 15.3

Functions
company_cmd.h File Reference

Command definitions related to companies. More...

`#include "command_type.h"`
`#include "company_type.h"`
`#include "livery.h"`

Go to the source code of this file.

## Functions
CommandCost | CmdCompanyCtrl (DoCommandFlags flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id)
| Control the companies: add, delete, etc.
CommandCost | CmdCompanyAllowListCtrl (DoCommandFlags flags, CompanyAllowListCtrlAction action, const std::string &public_key)
| Add or remove the given public key to the allow list of this company.
CommandCost | CmdGiveMoney (DoCommandFlags flags, Money money, CompanyID dest_company)
| Transfer funds (money) from one company to another.
CommandCost | CmdRenameCompany (DoCommandFlags flags, const std::string &text)
| Change the name of the company.
CommandCost | CmdRenamePresident (DoCommandFlags flags, const std::string &text)
| Change the name of the president.
CommandCost | CmdSetCompanyManagerFace (DoCommandFlags flags, uint style, uint32_t bits)
| Change the company manager's face.
CommandCost | CmdSetCompanyColour (DoCommandFlags flags, LiveryScheme scheme, bool primary, Colours colour)
| Change the company's company-colour.

## Detailed Description

Command definitions related to companies.

Definition in file company_cmd.h.

## Function Documentation

## ◆ CmdCompanyAllowListCtrl()

CommandCost CmdCompanyAllowListCtrl | ( | DoCommandFlags | flags,
|  | CompanyAllowListCtrlAction | action,
|  | const std::string & | public_key
| ) |  |

Add or remove the given public key to the allow list of this company.

Parameters

  flags | Operation to perform.
  action | The action to perform.
  public_key | The public key of the client to add or remove.

Returns
  The cost of this operation or an error.

Definition at line 1023 of file company_cmd.cpp.

References _current_company, CALCA_ADD, CALCA_REMOVE, CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), InvalidateWindowData(), NETWORK_PUBLIC_KEY_LENGTH, SetWindowDirty(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), WC_CLIENT_LIST, and WC_COMPANY.

## ◆ CmdCompanyCtrl()

CommandCost CmdCompanyCtrl | ( | DoCommandFlags | flags,
|  | CompanyCtrlAction | cca,
|  | CompanyID | company_id,
|  | CompanyRemoveReason | reason,
|  | ClientID | client_id
| ) |  |

Control the companies: add, delete, etc.

Parameters

  flags | operation to perform
  cca | action to perform
  company_id | company to perform the action on
  client_id | ClientID

Returns
  the cost of this operation or an error

Definition at line 881 of file company_cmd.cpp.

References _company_manager_face, _local_company, _network_own_client_id, _network_server, _networking, AI::BroadcastNewEvent(), CCA_DELETE, CCA_NEW, CCA_NEW_AI, ChangeOwnershipOfCompanyItems(), NetworkClientInfo::client_id, NetworkClientInfo::client_playas, CloseWindowById(), CMD_ERROR, COMPANY_SPECTATOR, CompanyAdminRemove(), CRR_END, DoStartupNewCompany(), Execute, NetworkClientInfo::GetByClientID(), GetEncodedString(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_goal_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_story_page_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, INVALID_OWNER, InvalidateWindowClassesData(), InvalidateWindowData(), CompanyProperties::is_ai, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), MarkWholeScreenDirty(), NetworkAdminCompanyNew(), NetworkServerNewCompany(), NetworkUpdateClientInfo(), Game::NewEvent(), ParseCompanyManagerFaceCode(), SetLocalCompany(), AI::Stop(), SyncCompanySettings(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), WC_CLIENT_LIST, WC_COMPANY_LEAGUE, WC_GAME_OPTIONS, WC_MAIN_TOOLBAR, WC_NETWORK_STATUS_WINDOW, WC_SCRIPT_LIST, WC_SCRIPT_SETTINGS, and WN_NETWORK_STATUS_WINDOW_JOIN.

## ◆ CmdGiveMoney()

CommandCost CmdGiveMoney | ( | DoCommandFlags | flags,
|  | Money | money,
|  | CompanyID | dest_company
| ) |  |

Transfer funds (money) from one company to another.

To prevent abuse in multiplayer games you can only send money to other companies if you have paid off your loan (either explicitly, or implicitly given the fact that you have more money than loan).

Parameters

  flags | operation to perform
  money | the amount of money to transfer; max 20.000.000
  dest_company | the company to transfer the money to

Returns
  the cost of this operation or an error

Definition at line 1316 of file company_cmd.cpp.

References _current_company, _networking, _settings_game, CMD_ERROR, CompanyProperties::current_loan, GameSettings::economy, Execute, EXPENSES_OTHER, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), GetDrawStringCompanyColour(), GetString(), EconomySettings::give_money, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), CompanyProperties::money, Backup< T >::Restore(), SubtractMoneyFromCompany(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ CmdRenameCompany()

CommandCost CmdRenameCompany | ( | DoCommandFlags | flags,
|  | const std::string & | text
| ) |  |

Change the name of the company.

Parameters

  flags | operation to perform
  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 1193 of file company_cmd.cpp.

References _current_company, AI::BroadcastNewEvent(), CMD_ERROR, CompanyAdminUpdate(), Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetString(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IsUniqueCompanyName(), MarkWholeScreenDirty(), MAX_LENGTH_COMPANY_NAME_CHARS, CompanyProperties::name, Game::NewEvent(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Utf8StringLength().

## ◆ CmdRenamePresident()

CommandCost CmdRenamePresident | ( | DoCommandFlags | flags,
|  | const std::string & | text
| ) |  |

Change the name of the president.

Parameters

  flags | operation to perform
  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 1240 of file company_cmd.cpp.

References _current_company, AI::BroadcastNewEvent(), CMD_ERROR, CompanyAdminUpdate(), Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), GetString(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, InvalidateWindowClassesData(), IsUniquePresidentName(), MarkWholeScreenDirty(), MAX_LENGTH_PRESIDENT_NAME_CHARS, CompanyProperties::name, CompanyProperties::name_1, Game::NewEvent(), CompanyProperties::president_name, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), Utf8StringLength(), and WC_COMPANY.

## ◆ CmdSetCompanyColour()

CommandCost CmdSetCompanyColour | ( | DoCommandFlags | flags,
|  | LiveryScheme | scheme,
|  | bool | primary,
|  | Colours | colour
| ) |  |

Change the company's company-colour.

Parameters

  flags | operation to perform
  scheme | scheme to set
  primary | set first/second colour
  colour | new colour for vehicles, property, etc.

Returns
  the cost of this operation or an error

Definition at line 1094 of file company_cmd.cpp.

References _company_colours, _current_company, BuildOwnerLegend(), CMD_ERROR, CompanyProperties::colour, CompanyAdminUpdate(), Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Iterate(), MarkWholeScreenDirty(), Livery::Primary, Livery::Secondary, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), UpdateCompanyLiveries(), UpdateObjectColours(), WC_COMPANY_VALUE, WC_DELIVERED_CARGO, WC_INCOME_GRAPH, WC_LINKGRAPH_LEGEND, WC_OPERATING_PROFIT, WC_PERFORMANCE_HISTORY, and WC_SMALLMAP.

## ◆ CmdSetCompanyManagerFace()

CommandCost CmdSetCompanyManagerFace | ( | DoCommandFlags | flags,
|  | uint | style,
|  | uint32_t | bits
| ) |  |

Change the company manager's face.

Parameters

  flags | operation to perform
  style | The style of the company manager face.
  bits | The bits of company manager face.

Returns
  the cost of this operation or an error

Definition at line 1057 of file company_cmd.cpp.

References _current_company, CompanyManagerFace::bits, CMD_ERROR, Execute, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::Get(), IsValidCompanyManagerFace(), MarkWholeScreenDirty(), SetCompanyManagerFaceStyle(), and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().