# 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 "company_manager_face.h"`
`#include "strings_func.h"`
`#include "gfx_func.h"`
`#include "functions.h"`
`#include "vehicle_func.h"`
`#include "company_func.h"`
`#include "company_gui.h"`
`#include "vehicle_base.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Functions
CommandCost | CmdSetCompanyManagerFace (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the company manager's face.
CommandCost | CmdSetCompanyColour (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the company's company-colour.
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 bool | IsUniqueCompanyName (const char *name)
CommandCost | CmdRenameCompany (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the name of the company.
static bool | IsUniquePresidentName (const char *name)
CommandCost | CmdRenamePresident (TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
| Change the name of the president.
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 326 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 196 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, LOAN_INTERVAL, max(), min(), 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 419 of file misc_cmd.cpp.

References _settings_game, CMD_ERROR, DC_EXEC, GameSettings::economy, CommandCost::GetCost(), EconomySettings::give_money, and min().

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

References CMD_ERROR, DC_EXEC, LOAN_INTERVAL, 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.

This is normally only enabled in offline mode, but if there is a debug build, you can cheat (to test).

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

References CMD_ERROR.

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

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

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

Change the name of the company.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 250 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, MarkWholeScreenDirty(), MAX_LENGTH_COMPANY_NAME_BYTES, return_cmd_error, and StrEmpty().

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

Change the name of the president.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | unused
  | text | the new name or an empty string when resetting to the default

Returns:
  the cost of this operation or an error

Definition at line 288 of file misc_cmd.cpp.

References CMD_ERROR, CMD_RENAME_COMPANY, DC_EXEC, DoCommand(), lengthof, MarkWholeScreenDirty(), MAX_LENGTH_PRESIDENT_NAME_BYTES, return_cmd_error, and StrEmpty().

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

Change the company's company-colour.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | bitstuffed: p1 bits 0-7 scheme to set p1 bits 8-9 set in use state or first/second colour
  | p2 | new colour for vehicles, property, etc.
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 61 of file misc_cmd.cpp.

References _company_colours, CMD_ERROR, DC_EXEC, GB(), and MarkWholeScreenDirty().

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

Change the company manager's face.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | unused
  | p2 | face bitmasked
  | text | unused

Returns:
  the cost of this operation or an error

Definition at line 38 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, IsValidCompanyManagerFace(), and MarkWholeScreenDirty().