OpenTTD Source 20260208-master-g43af8e94d0
misc_cmd.h File Reference

Miscellaneous command definitions. More...

#include "command_type.h"
#include "economy_type.h"
#include "openttd.h"

Go to the source code of this file.

Enumerations

enum class  LoanCommand : uint8_t { Interval , Max , Amount }
 Different ways to determine the amount to loan/repay. More...

Functions

CommandCost CmdMoneyCheat (DoCommandFlags, Money amount)
 Change the financial flow of your company.
CommandCost CmdChangeBankBalance (DoCommandFlags flags, TileIndex tile, Money delta, CompanyID company, ExpensesType expenses_type)
 Change the bank bank balance of a company by inserting or removing money without affecting the loan.
CommandCost CmdIncreaseLoan (DoCommandFlags flags, LoanCommand cmd, Money amount)
 Increase the loan of your company.
CommandCost CmdDecreaseLoan (DoCommandFlags flags, LoanCommand cmd, Money amount)
 Decrease the loan of your company.
CommandCost CmdSetCompanyMaxLoan (DoCommandFlags flags, CompanyID company, Money amount)
 Sets the max loan amount of your company.
CommandCost CmdPause (DoCommandFlags flags, PauseMode mode, bool pause)
 Pause/Unpause the game (server-only).

Detailed Description

Miscellaneous command definitions.

Definition in file misc_cmd.h.

Enumeration Type Documentation

◆ LoanCommand

enum class LoanCommand : uint8_t
strong

Different ways to determine the amount to loan/repay.

Enumerator
Interval 

Loan/repay LOAN_INTERVAL.

Max 

Loan/repay the maximum amount permitting money/settings.

Amount 

Loan/repay the given amount.

Definition at line 18 of file misc_cmd.h.

Function Documentation

◆ CmdChangeBankBalance()

CommandCost CmdChangeBankBalance ( DoCommandFlags flags,
TileIndex tile,
Money delta,
CompanyID company,
ExpensesType expenses_type )

Change the bank bank balance of a company by inserting or removing money without affecting the loan.

Parameters
flagsoperation to perform
tiletile to show text effect on (if not 0)
deltathe amount of money to receive (if positive), or spend (if negative)
companythe company ID.
expenses_typethe expenses type which should register the cost/income
See also
ExpensesType.
Returns
zero cost or an error

Definition at line 240 of file misc_cmd.cpp.

References _current_company, CMD_ERROR, Execute, EXPENSES_END, GetTilePixelZ(), OWNER_DEITY, ShowCostOrIncomeAnimation(), SubtractMoneyFromCompany(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), TILE_SIZE, TileX(), and TileY().

◆ CmdDecreaseLoan()

CommandCost CmdDecreaseLoan ( DoCommandFlags flags,
LoanCommand cmd,
Money amount )

Decrease the loan of your company.

Parameters
flagsoperation to perform
cmdwhen LoanCommand::Interval: pays back LOAN_INTERVAL, when LoanCommand::Max: pays back the maximum loan permitting money (press CTRL), when LoanCommand::Amount: pays back the amount specified in amount
amountamount to decrease the loan with, multitude of LOAN_INTERVAL. Only used when cmd == LoanCommand::Amount.
Returns
the cost of this operation or an error

Definition at line 87 of file misc_cmd.cpp.

References _current_company, Amount, CMD_ERROR, CommandCostWithParam(), CompanyProperties::current_loan, Execute, GetAvailableMoneyForCommand(), Interval, InvalidateCompanyWindows(), LOAN_INTERVAL, Max, CompanyProperties::money, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ CmdIncreaseLoan()

CommandCost CmdIncreaseLoan ( DoCommandFlags flags,
LoanCommand cmd,
Money amount )

Increase the loan of your company.

Parameters
flagsoperation to perform
cmdwhen LoanCommand::Interval: loans LOAN_INTERVAL, when LoanCommand::Max: loans the maximum loan permitting money (press CTRL), when LoanCommand::Amount: loans the amount specified in amount
amountamount to increase the loan with, multitude of LOAN_INTERVAL. Only used when cmd == LoanCommand::Amount.
Returns
the cost of this operation or an error

Definition at line 41 of file misc_cmd.cpp.

References _current_company, Amount, CMD_ERROR, CommandCostWithParam(), CompanyProperties::current_loan, Execute, EXPENSES_OTHER, Company::GetMaxLoan(), Interval, InvalidateCompanyWindows(), LOAN_INTERVAL, Max, CompanyProperties::money, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

◆ CmdMoneyCheat()

CommandCost CmdMoneyCheat ( DoCommandFlags ,
Money amount )

Change the financial flow of your company.

Parameters
amountthe amount of money to receive (if positive), or spend (if negative)
Returns
the cost of this operation or an error

Definition at line 226 of file misc_cmd.cpp.

References EXPENSES_OTHER.

◆ CmdPause()

CommandCost CmdPause ( DoCommandFlags flags,
PauseMode mode,
bool pause )

Pause/Unpause the game (server-only).

Set or unset a bit in the pause mode. If pause mode is zero the game is unpaused. A bitset is used instead of a boolean value/counter to have more control over the game when saving/loading, etc.

Parameters
flagsoperation to perform
modethe pause mode to change
pausetrue pauses, false unpauses this mode
Returns
the cost of this operation or an error

Definition at line 170 of file misc_cmd.cpp.

References _networking, _pause_mode, ActiveClients, AskUnsafeUnpauseCallback(), CMD_ERROR, CommandDuringPause, Error, Execute, GameScript, GetEncodedString(), VideoDriver::GetInstance(), Join, LinkGraph, NetworkHandlePauseChange(), Normal, SaveLoad, VideoDriver::SetScreensaverInhibited(), SetWindowDirty(), ShowQuery(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), WC_MAIN_TOOLBAR, and WC_STATUS_BAR.

◆ CmdSetCompanyMaxLoan()

CommandCost CmdSetCompanyMaxLoan ( DoCommandFlags flags,
CompanyID company,
Money amount )

Sets the max loan amount of your company.

Does not respect the global loan setting.

Parameters
flagsFlags whether to test or execute this command.
companythe company ID.
amountthe new max loan amount, will be rounded down to the multitude of LOAN_INTERVAL. If set to COMPANY_MAX_LOAN_DEFAULT reset the max loan to default(global) value.
Returns
zero cost or an error

Definition at line 128 of file misc_cmd.cpp.

References _current_company, CMD_ERROR, Execute, InvalidateCompanyWindows(), LOAN_INTERVAL, CompanyProperties::max_loan, MAX_LOAN_LIMIT, OWNER_DEITY, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().