# 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 "openttd.h"`
`#include "command_func.h"`
`#include "economy_func.h"`
`#include "window_func.h"`
`#include "textbuf_gui.h"`
`#include "network/network.h"`
`#include "company_manager_face.h"`
`#include "strings_func.h"`
`#include "gfx_func.h"`
`#include "functions.h"`
`#include "vehicle_func.h"`
`#include "string_func.h"`
`#include "company_func.h"`
`#include "company_base.h"`
`#include "company_gui.h"`
`#include "settings_type.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 310 of file misc_cmd.cpp.

References CMD_PAUSE, and DoCommandP().

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

Definition at line 184 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, max(), min(), and return_cmd_error.

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

Definition at line 377 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

Definition at line 140 of file misc_cmd.cpp.

References CMD_ERROR, DC_EXEC, and return_cmd_error.

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

Definition at line 360 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).

Increase or decrease the pause counter. If the counter is zero, the game is unpaused. A counter is used instead of a boolean value to have more control over the game when saving/loading, etc.

Parameters:

  | tile | unused
  | flags | operation to perform
  | p1 | 0 = decrease pause counter; 1 = increase pause counter
  | p2 | unused

Definition at line 324 of file misc_cmd.cpp.

References AskUnsafeUnpauseCallback(), DC_EXEC, InvalidateWindow(), 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

Definition at line 236 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

Definition at line 272 of file misc_cmd.cpp.

References buf, 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.

Definition at line 53 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

Definition at line 32 of file misc_cmd.cpp.

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