OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- Data Structures
- Class Hierarchy
- Data Fields

Public Member Functions | Static Public Member Functions | Static Public Attributes
EngineOverrideManager Struct Reference

Stores the mapping of EngineID to the internal id of newgrfs. More...

`#include <engine_base.h>`

Inheritance diagram for EngineOverrideManager:

## Public Member Functions
void | ResetToDefaultMapping ()
| Initializes the EngineOverrideManager with the default engines.
EngineID | GetID (VehicleType type, uint16 grf_local_id, uint32 grfid)
| Looks up an EngineID in the EngineOverrideManager.
Public Member Functions inherited from SmallVector< EngineIDMapping, 256 >
| SmallVector (const SmallVector &other)
| Copy constructor.
| SmallVector (const SmallVector< EngineIDMapping, X > &other)
| Generic copy constructor.
SmallVector & | operator= (const SmallVector &other)
| Assignment.
SmallVector & | operator= (const SmallVector< EngineIDMapping, X > &other)
| Generic assignment.
void | Assign (const SmallVector< EngineIDMapping, X > &other)
| Assign items from other vector.
void | Clear ()
| Remove all items from the list.
void | Reset ()
| Remove all items from the list and free allocated memory.
void | Compact ()
| Compact the list down to the smallest block size boundary.
EngineIDMapping * | Append (uint to_add=1)
| Append an item and return it.
void | Resize (uint num_items)
| Set the size of the vector, effectively truncating items from the end or appending uninitialised ones.
const EngineIDMapping * | Find (const EngineIDMapping &item) const
| Search for the first occurrence of an item.
EngineIDMapping * | Find (const EngineIDMapping &item)
| Search for the first occurrence of an item.
int | FindIndex (const EngineIDMapping &item) const
| Search for the first occurrence of an item.
bool | Contains (const EngineIDMapping &item) const
| Tests whether a item is present in the vector.
void | Erase (EngineIDMapping *item)
| Removes given item from this vector.
void | ErasePreservingOrder (uint pos, uint count=1)
| Remove items from the vector while preserving the order of other items.
bool | Include (const EngineIDMapping &item)
| Tests whether a item is present in the vector, and appends it to the end if not.
uint | Length () const
| Get the number of items in the list.
const EngineIDMapping * | Begin () const
| Get the pointer to the first item (const)
EngineIDMapping * | Begin ()
| Get the pointer to the first item.
const EngineIDMapping * | End () const
| Get the pointer behind the last valid item (const)
EngineIDMapping * | End ()
| Get the pointer behind the last valid item.
const EngineIDMapping * | Get (uint index) const
| Get the pointer to item "number" (const)
EngineIDMapping * | Get (uint index)
| Get the pointer to item "number".
const EngineIDMapping & | operator[] (uint index) const
| Get item "number" (const)
EngineIDMapping & | operator[] (uint index)
| Get item "number".

## Static Public Member Functions
static bool | ResetToCurrentNewGRFConfig ()
| Tries to reset the engine mapping to match the current NewGRF configuration.

## Static Public Attributes
static const uint | NUM_DEFAULT_ENGINES = _engine_counts[VEH_TRAIN] + _engine_counts[VEH_ROAD] + _engine_counts[VEH_SHIP] + _engine_counts[VEH_AIRCRAFT]
| Number of default entries.

## Additional Inherited Members
Protected Attributes inherited from SmallVector< EngineIDMapping, 256 >
EngineIDMapping * | data
| The pointer to the first item.
uint | items
| The number of items stored.
uint | capacity
| The available space for storing items.

## Detailed Description

Stores the mapping of EngineID to the internal id of newgrfs.

Note: This is not part of Engine, as the data in the EngineOverrideManager and the engine pool get resetted in different cases.

Definition at line 159 of file engine_base.h.

## Member Function Documentation

EngineID EngineOverrideManager::GetID | ( | VehicleType | type,
|  | uint16 | grf_local_id,
|  | uint32 | grfid
| ) |  |

Looks up an EngineID in the EngineOverrideManager.

Parameters

  type | Vehicle type
  grf_local_id | The local id in the newgrf
  grfid | The GrfID that defines the scope of grf_local_id. If a newgrf overrides the engines of another newgrf, the "scope grfid" is the ID of the overridden newgrf. If dynnamic_engines is disabled, all newgrf share the same ID scope identified by INVALID_GRFID.

Returns
  The engine ID if present, or INVALID_ENGINE if not.

Definition at line 511 of file engine.cpp.

References SmallVector< EngineIDMapping, 256 >::Begin(), SmallVector< EngineIDMapping, 256 >::End(), and INVALID_ENGINE.

Referenced by CommitVehicleListOrderChanges(), GetNewEngine(), and GetNewEngineID().

bool EngineOverrideManager::ResetToCurrentNewGRFConfig | ( |  | ) |
| static

Tries to reset the engine mapping to match the current NewGRF configuration.

This is only possible when there are currently no vehicles in the game.

Returns
  false if resetting failed due to present vehicles.

Definition at line 528 of file engine.cpp.

References FOR_ALL_VEHICLES, IsCompanyBuildableVehicleType(), ReloadNewGRFData(), and ResetToDefaultMapping().

Referenced by ChangeDynamicEngines(), DEF_CONSOLE_CMD(), and ResetLandscapeConfirmationCallback().

The documentation for this struct was generated from the following files:

- src/engine_base.h
- src/engine.cpp