# 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 "core/backup_type.hpp"`
`#include "table/strings.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.
CommandCost | CmdDecreaseLoan (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Decrease the loan of your company.
static void | AskUnsafeUnpauseCallback (Window *w, bool confirmed)
| In case of an unsafe unpause, we want the user to confirm that it might crash.
CommandCost | CmdPause (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Pause/Unpause the game (server-only).
CommandCost | CmdMoneyCheat (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the financial flow of your company.
CommandCost | CmdGiveMoney (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Transfer funds (money) from one company to another.

## 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

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:

  | w | unused
  | confirmed | whether the user confirms his/her action

Definition at line 126 of file misc_cmd.cpp.

References CMD_PAUSE, DoCommandP(), and PM_PAUSED_ERROR.

Referenced by CmdPause().

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

Decrease the loan of your company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | amount to decrease the loan with, multitude of LOAN_INTERVAL. Only used when p2 == 2.
  | p2 | when 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
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 85 of file misc_cmd.cpp.

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

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 explicitely, or implicitely given the fact that you have more money than loan).

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the amount of money to transfer; max 20.000.000
  | p2 | the company to transfer the money to
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 217 of file misc_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, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), EconomySettings::give_money, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), min(), CompanyProperties::money, Backup< T >::Restore(), and SubtractMoneyFromCompany().

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

Increase the loan of your company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | amount to increase the loan with, multitude of LOAN_INTERVAL. Only used when p2 == 2.
  | p2 | when 0: loans LOAN_INTERVAL when 1: loans the maximum loan permitting money (press CTRL), when 2: loans the amount specified in p1
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 38 of file misc_cmd.cpp.

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

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

Change the financial flow of your company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | the amount of money to receive (if negative), or spend (if positive)
  | p2 | unused
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 200 of file misc_cmd.cpp.

References EXPENSES_OTHER.

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:

  | tile | unused
  | flags | operation to perform
  | p1 | the pause mode to change
  | p2 | 1 pauses, 0 unpauses this mode
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 143 of file misc_cmd.cpp.

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