OpenTTD Source: src/engine_cmd.h File Reference

OpenTTD Source 15.0-beta1

Functions
engine_cmd.h File Reference

Command definitions related to engines. More...

`#include "command_type.h"`

Go to the source code of this file.

## Functions
CommandCost | CmdWantEnginePreview (DoCommandFlag flags, EngineID engine_id)
| Accept an engine prototype.
CommandCost | CmdEngineCtrl (DoCommandFlag flags, EngineID engine_id, CompanyID company_id, bool allow)
| Allow or forbid a specific company to use an engine.
CommandCost | CmdRenameEngine (DoCommandFlag flags, EngineID engine_id, const std::string &text)
| Rename an engine.
CommandCost | CmdSetVehicleVisibility (DoCommandFlag flags, EngineID engine_id, bool hide)
| Set the visibility of an engine.

## Detailed Description

Command definitions related to engines.

Definition in file engine_cmd.h.

## Function Documentation

## ◆ CmdEngineCtrl()

CommandCost CmdEngineCtrl | ( | DoCommandFlag | flags,
|  | EngineID | engine_id,
|  | CompanyID | company_id,
|  | bool | allow
| ) |  |

Allow or forbid a specific company to use an engine.

Parameters

  flags | operation to perform
  engine_id | engine id
  company_id | Company to allow/forbid the use of an engine.
  allow | false to forbid, true to allow.

Returns
  the cost of this operation or an error

Definition at line 1058 of file engine.cpp.

References _current_company, CMD_ERROR, DC_EXEC, DisableEngineForCompany(), EnableEngineForCompany(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::IsValidID(), and OWNER_DEITY.

## ◆ CmdRenameEngine()

CommandCost CmdRenameEngine | ( | DoCommandFlag | flags,
|  | EngineID | engine_id,
|  | const std::string & | text
| ) |  |

Rename an engine.

Parameters

  flags | operation to perform
  engine_id | engine ID to rename
  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 1220 of file engine.cpp.

References CMD_ERROR, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), IsUniqueEngineName(), MarkWholeScreenDirty(), MAX_LENGTH_ENGINE_NAME_CHARS, Engine::name, and Utf8StringLength().

## ◆ CmdSetVehicleVisibility()

CommandCost CmdSetVehicleVisibility | ( | DoCommandFlag | flags,
|  | EngineID | engine_id,
|  | bool | hide
| ) |  |

Set the visibility of an engine.

Parameters

  flags | Operation to perform.
  engine_id | Engine id..
  hide | Set for hidden, unset for visible.

Returns
  The cost of this operation or an error.

Definition at line 1019 of file engine.cpp.

References _current_company, AddRemoveEngineFromAutoreplaceAndBuildWindows(), AssignBit(), CMD_ERROR, Engine::company_hidden, DC_EXEC, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsEngineBuildable(), MAX_COMPANIES, and Engine::type.

## ◆ CmdWantEnginePreview()

CommandCost CmdWantEnginePreview | ( | DoCommandFlag | flags,
|  | EngineID | engine_id
| ) |  |

Accept an engine prototype.

XXX - it is possible that the top-company changes while you are waiting to accept the offer? Then it becomes invalid

Parameters

  flags | operation to perform
  engine_id | engine-prototype offered

Returns
  the cost of this operation or an error

Definition at line 1040 of file engine.cpp.

References _current_company, AcceptEnginePreview(), CMD_ERROR, DC_EXEC, ENGINE_EXCLUSIVE_PREVIEW, Engine::flags, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::GetIfValid(), and Engine::preview_company.