OpenTTD Source 20241224-master-gee860a5c8e
misc_cmd.cpp File Reference

Some misc functions that are better fitted in other files, but never got moved there... More...

#include "stdafx.h"
#include "command_func.h"
#include "economy_func.h"
#include "window_func.h"
#include "textbuf_gui.h"
#include "network/network.h"
#include "network/network_func.h"
#include "strings_func.h"
#include "company_func.h"
#include "company_gui.h"
#include "company_base.h"
#include "tile_map.h"
#include "texteff.hpp"
#include "core/backup_type.hpp"
#include "misc_cmd.h"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

CommandCost CmdIncreaseLoan (DoCommandFlag flags, LoanCommand cmd, Money amount)
 Increase the loan of your company.
 
CommandCost CmdDecreaseLoan (DoCommandFlag flags, LoanCommand cmd, Money amount)
 Decrease the loan of your company.
 
CommandCost CmdSetCompanyMaxLoan (DoCommandFlag flags, CompanyID company, Money amount)
 Sets the max loan amount of your company.
 
static void AskUnsafeUnpauseCallback (Window *, bool confirmed)
 In case of an unsafe unpause, we want the user to confirm that it might crash.
 
CommandCost CmdPause (DoCommandFlag flags, PauseMode mode, bool pause)
 Pause/Unpause the game (server-only).
 
CommandCost CmdMoneyCheat (DoCommandFlag, Money amount)
 Change the financial flow of your company.
 
CommandCost CmdChangeBankBalance (DoCommandFlag 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.
 

Detailed Description

Some misc functions that are better fitted in other files, but never got moved there...

Definition in file misc_cmd.cpp.

Function Documentation

◆ AskUnsafeUnpauseCallback()

static void AskUnsafeUnpauseCallback ( Window ,
bool  confirmed 
)
static

In case of an unsafe unpause, we want the user to confirm that it might crash.

Parameters
confirmedwhether the user confirmed their action

Definition at line 152 of file misc_cmd.cpp.

References PM_PAUSED_ERROR.

Referenced by CmdPause().

◆ CmdChangeBankBalance()

CommandCost CmdChangeBankBalance ( DoCommandFlag  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 236 of file misc_cmd.cpp.

References _current_company, CMD_ERROR, DC_EXEC, EXPENSES_END, GetTilePixelZ(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), OWNER_DEITY, Backup< T >::Restore(), ShowCostOrIncomeAnimation(), SubtractMoneyFromCompany(), TILE_SIZE, TileX(), and TileY().

◆ CmdDecreaseLoan()

CommandCost CmdDecreaseLoan ( DoCommandFlag  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 86 of file misc_cmd.cpp.

References _current_company, CMD_ERROR, CompanyProperties::current_loan, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), GetAvailableMoneyForCommand(), InvalidateCompanyWindows(), LOAN_INTERVAL, CompanyProperties::money, and SetDParam().

◆ CmdIncreaseLoan()

CommandCost CmdIncreaseLoan ( DoCommandFlag  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 39 of file misc_cmd.cpp.

References _current_company, CMD_ERROR, CompanyProperties::current_loan, DC_EXEC, EXPENSES_OTHER, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Company::GetMaxLoan(), InvalidateCompanyWindows(), LOAN_INTERVAL, CompanyProperties::money, and SetDParam().

◆ CmdMoneyCheat()

CommandCost CmdMoneyCheat ( DoCommandFlag  flags,
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 222 of file misc_cmd.cpp.

References EXPENSES_OTHER.

◆ CmdPause()

CommandCost CmdPause ( DoCommandFlag  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 169 of file misc_cmd.cpp.

References _networking, _pause_mode, AskUnsafeUnpauseCallback(), CMD_ERROR, DC_EXEC, NetworkHandlePauseChange(), PM_COMMAND_DURING_PAUSE, PM_PAUSED_ACTIVE_CLIENTS, PM_PAUSED_ERROR, PM_PAUSED_GAME_SCRIPT, PM_PAUSED_JOIN, PM_PAUSED_LINK_GRAPH, PM_PAUSED_NORMAL, PM_PAUSED_SAVELOAD, PM_UNPAUSED, SetWindowDirty(), ShowQuery(), WC_MAIN_TOOLBAR, and WC_STATUS_BAR.

◆ CmdSetCompanyMaxLoan()

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

Sets the max loan amount of your company.

Does not respect the global loan setting.

Parameters
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 127 of file misc_cmd.cpp.

References _current_company, CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), InvalidateCompanyWindows(), LOAN_INTERVAL, CompanyProperties::max_loan, MAX_LOAN_LIMIT, and OWNER_DEITY.