OpenTTD Source: src/autoreplace_cmd.h File Reference

OpenTTD Source 14.0-RC3

Functions
autoreplace_cmd.h File Reference
`#include "command_type.h"`
`#include "vehicle_type.h"`
`#include "engine_type.h"`
`#include "group_type.h"`

Go to the source code of this file.

## Functions
CommandCost | CmdAutoreplaceVehicle (DoCommandFlag flags, VehicleID veh_id)
| Autoreplaces a vehicle Trains are replaced as a whole chain, free wagons in depot are replaced on their own. More...
CommandCost | CmdSetAutoReplace (DoCommandFlag flags, GroupID id_g, EngineID old_engine_type, EngineID new_engine_type, bool when_old)
| Change engine renewal parameters. More...

## Detailed Description

Command definitions related to autoreplace.

Definition in file autoreplace_cmd.h.

## Function Documentation

## ◆ CmdAutoreplaceVehicle()

CommandCost CmdAutoreplaceVehicle | ( | DoCommandFlag | flags,
|  | VehicleID | veh_id
| ) |  |

Autoreplaces a vehicle Trains are replaced as a whole chain, free wagons in depot are replaced on their own.

Parameters

  flags | type of operation
  veh_id | Index of vehicle

Returns
  the cost of this operation or an error

Definition at line 732 of file autoreplace_cmd.cpp.

References _current_company, CommandCost::AddCost(), CheckOwnership(), CMD_ERROR, DC_EXEC, DoCmdStartStopVehicle(), EXPENSES_NEW_VEHICLES, CommandCost::Failed(), SpecializedVehicle< T, Type >::First(), Group::flags, SpecializedVehicle< Train, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), CommandCost::GetCost(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::GetIfValid(), GetNewEngineType(), Train::GetNextUnit(), GF_REPLACE_WAGON_REMOVAL, Vehicle::group_id, HasBit(), INVALID_ENGINE, Vehicle::IsArticulatedPart(), Vehicle::IsChainInDepot(), Vehicle::IsFrontEngine(), Vehicle::IsPrimaryVehicle(), GroundVehicle< T, Type >::IsRearDualheaded(), Vehicle::IsStoppedInDepot(), Vehicle::owner, CompanySettings::renew_keep_length, ReplaceChain(), ReplaceFreeUnit(), RestoreRandomSeeds(), SaveRandomSeeds(), CompanyProperties::settings, CommandCost::Succeeded(), BaseVehicle::type, VEH_TRAIN, Vehicle::vehstatus, VS_CRASHED, and VS_STOPPED.

## ◆ CmdSetAutoReplace()

CommandCost CmdSetAutoReplace | ( | DoCommandFlag | flags,
|  | GroupID | id_g,
|  | EngineID | old_engine_type,
|  | EngineID | new_engine_type,
|  | bool | when_old
| ) |  |

Change engine renewal parameters.

Parameters

  flags | operation to perform
  id_g | engine group
  old_engine_type | old engine type
  new_engine_type | new engine type
  when_old | replace when engine gets old?

Returns
  the cost of this operation or an error

Definition at line 820 of file autoreplace_cmd.cpp.

References _current_company, CMD_ERROR, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), IsAllGroupID(), and Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::IsValidID().