OpenTTD Source 20241224-master-gf74b0cf984
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 (DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id)
 Control the companies: add, delete, etc.
 
CommandCost CmdCompanyAllowListCtrl (DoCommandFlag flags, CompanyAllowListCtrlAction action, const std::string &public_key)
 Add or remove the given public key to the allow list of this company.
 
CommandCost CmdGiveMoney (DoCommandFlag flags, Money money, CompanyID dest_company)
 Transfer funds (money) from one company to another.
 
CommandCost CmdRenameCompany (DoCommandFlag flags, const std::string &text)
 Change the name of the company.
 
CommandCost CmdRenamePresident (DoCommandFlag flags, const std::string &text)
 Change the name of the president.
 
CommandCost CmdSetCompanyManagerFace (DoCommandFlag flags, CompanyManagerFace cmf)
 Change the company manager's face.
 
CommandCost CmdSetCompanyColour (DoCommandFlag 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 ( DoCommandFlag  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 1004 of file company_cmd.cpp.

References _current_company, CALCA_ADD, CALCA_REMOVE, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), InvalidateWindowData(), NETWORK_PUBLIC_KEY_LENGTH, SetWindowDirty(), WC_CLIENT_LIST, and WC_COMPANY.

◆ CmdCompanyCtrl()

CommandCost CmdCompanyCtrl ( DoCommandFlag  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 864 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, DC_EXEC, DoStartupNewCompany(), NetworkClientInfo::GetByClientID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_goal_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_story_page_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, INVALID_COMPANY, INVALID_OWNER, InvalidateWindowClassesData(), InvalidateWindowData(), CompanyProperties::is_ai, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), MarkWholeScreenDirty(), MAX_COMPANIES, NetworkAdminCompanyNew(), NetworkServerNewCompany(), NetworkUpdateClientInfo(), Game::NewEvent(), SetDParam(), SetDParamStr(), SetLocalCompany(), AI::Stop(), SyncCompanySettings(), 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 ( DoCommandFlag  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 1296 of file company_cmd.cpp.

References _current_company, _networking, _settings_game, CMD_ERROR, CompanyProperties::current_loan, DC_EXEC, GameSettings::economy, EXPENSES_OTHER, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), GetDrawStringCompanyColour(), GetString(), EconomySettings::give_money, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), CompanyProperties::money, Backup< T >::Restore(), SetDParam(), and SubtractMoneyFromCompany().

◆ CmdRenameCompany()

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

Change the name of the company.

Parameters
flagsoperation to perform
textthe new name or an empty string when resetting to the default
Returns
the cost of this operation or an error

Definition at line 1169 of file company_cmd.cpp.

References _current_company, CMD_ERROR, CompanyAdminUpdate(), DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), IsUniqueCompanyName(), MarkWholeScreenDirty(), MAX_LENGTH_COMPANY_NAME_CHARS, CompanyProperties::name, and Utf8StringLength().

◆ CmdRenamePresident()

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

◆ CmdSetCompanyColour()

◆ CmdSetCompanyManagerFace()

CommandCost CmdSetCompanyManagerFace ( DoCommandFlag  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 1037 of file company_cmd.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), IsValidCompanyManagerFace(), and MarkWholeScreenDirty().