OpenTTD Source 20250312-master-gcdcc6b491d
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, CompanyManagerFace cmf)
 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
flagsOperation to perform.
actionThe action to perform.
public_keyThe public key of the client to add or remove.
Returns
The cost of this operation or an error.

Definition at line 990 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
flagsoperation to perform
ccaaction to perform
company_idcompany to perform the action on
client_idClientID
Returns
the cost of this operation or an error

Definition at line 853 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<&_story_page_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_goal_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(), 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
flagsoperation to perform
moneythe amount of money to transfer; max 20.000.000
dest_companythe company to transfer the money to
Returns
the cost of this operation or an error

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

◆ CmdRenamePresident()

◆ CmdSetCompanyColour()

◆ CmdSetCompanyManagerFace()

CommandCost CmdSetCompanyManagerFace ( DoCommandFlags  flags,
CompanyManagerFace  cmf 
)

Change the company manager's face.

Parameters
flagsoperation to perform
cmfface bitmasked
Returns
the cost of this operation or an error

Definition at line 1023 of file company_cmd.cpp.

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