OpenTTD
Functions
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 "cmd_helper.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 "core/backup_type.hpp"
#include "table/strings.h"
#include "safeguards.h"

Go to the source code of this file.

Functions

CommandCost CmdIncreaseLoan (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Increase the loan of your company. More...
 
CommandCost CmdDecreaseLoan (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Decrease the loan of your company. More...
 
static void AskUnsafeUnpauseCallback (Window *w, bool confirmed)
 In case of an unsafe unpause, we want the user to confirm that it might crash. More...
 
CommandCost CmdPause (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Pause/Unpause the game (server-only). More...
 
CommandCost CmdMoneyCheat (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Change the financial flow of your company. More...
 
CommandCost CmdChangeBankBalance (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Change the bank bank balance of a company by inserting or removing money without affecting the loan. More...
 
CommandCost CmdGiveMoney (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 Transfer funds (money) from one company to another. More...
 

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 w,
bool  confirmed 
)
static

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

Parameters
wunused
confirmedwhether the user confirms his/her action

Definition at line 129 of file misc_cmd.cpp.

References CMD_PAUSE, DoCommandP(), and PM_PAUSED_ERROR.

Referenced by CmdPause().

◆ CmdChangeBankBalance()

CommandCost CmdChangeBankBalance ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

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

Parameters
tileunused
flagsoperation to perform
p1the amount of money to receive (if positive), or spend (if negative)
p2(bit 0-7) - the company ID. (bit 8-15) - the expenses type which should register the cost/income
See also
ExpensesType.
Parameters
textunused
Returns
zero cost or an error

Definition at line 220 of file misc_cmd.cpp.

◆ CmdDecreaseLoan()

CommandCost CmdDecreaseLoan ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Decrease the loan of your company.

Parameters
tileunused
flagsoperation to perform
p1amount to decrease the loan with, multitude of LOAN_INTERVAL. Only used when p2 == 2.
p2when 0: pays back LOAN_INTERVAL when 1: pays back the maximum loan permitting money (press CTRL), when 2: pays back the amount specified in p1
textunused
Returns
the cost of this operation or an error

Definition at line 88 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(), InvalidateCompanyWindows(), LOAN_INTERVAL, max(), min(), CompanyProperties::money, return_cmd_error, and SetDParam().

◆ CmdGiveMoney()

CommandCost CmdGiveMoney ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

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
tileunused
flagsoperation to perform
p1the amount of money to transfer; max 20.000.000
p2the company to transfer the money to
textunused
Returns
the cost of this operation or an error

Definition at line 254 of file misc_cmd.cpp.

References _current_company, _settings_game, CMD_ERROR, GameSettings::economy, EXPENSES_OTHER, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), EconomySettings::give_money, and min().

◆ CmdIncreaseLoan()

CommandCost CmdIncreaseLoan ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Increase the loan of your company.

Parameters
tileunused
flagsoperation to perform
p1amount to increase the loan with, multitude of LOAN_INTERVAL. Only used when p2 == 2.
p2when 0: loans LOAN_INTERVAL when 1: loans the maximum loan permitting money (press CTRL), when 2: loans the amount specified in p1
textunused
Returns
the cost of this operation or an error

Definition at line 41 of file misc_cmd.cpp.

References _current_company, CompanyProperties::current_loan, and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get().

◆ CmdMoneyCheat()

CommandCost CmdMoneyCheat ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

Change the financial flow of your company.

Parameters
tileunused
flagsoperation to perform
p1the amount of money to receive (if positive), or spend (if negative)
p2unused
textunused
Returns
the cost of this operation or an error

Definition at line 205 of file misc_cmd.cpp.

References EXPENSES_OTHER.

◆ CmdPause()

CommandCost CmdPause ( TileIndex  tile,
DoCommandFlag  flags,
uint32  p1,
uint32  p2,
const char *  text 
)

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
tileunused
flagsoperation to perform
p1the pause mode to change
p21 pauses, 0 unpauses this mode
textunused
Returns
the cost of this operation or an error

Definition at line 148 of file misc_cmd.cpp.

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