OpenTTD
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:
SmallVector< EngineIDMapping, 256 >

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. More...
 
- Public Member Functions inherited from SmallVector< EngineIDMapping, 256 >
 SmallVector (const SmallVector &other)
 Copy constructor. More...
 
 SmallVector (const SmallVector< EngineIDMapping, X > &other)
 Generic copy constructor. More...
 
SmallVectoroperator= (const SmallVector &other)
 Assignment. More...
 
SmallVectoroperator= (const SmallVector< EngineIDMapping, X > &other)
 Generic assignment. More...
 
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.
 
EngineIDMappingAppend (uint to_add=1)
 Append an item and return it. More...
 
void Resize (uint num_items)
 Set the size of the vector, effectively truncating items from the end or appending uninitialised ones. More...
 
const EngineIDMappingFind (const EngineIDMapping &item) const
 Search for the first occurrence of an item. More...
 
EngineIDMappingFind (const EngineIDMapping &item)
 Search for the first occurrence of an item. More...
 
int FindIndex (const EngineIDMapping &item) const
 Search for the first occurrence of an item. More...
 
bool Contains (const EngineIDMapping &item) const
 Tests whether a item is present in the vector. More...
 
void Erase (EngineIDMapping *item)
 Removes given item from this vector. More...
 
void ErasePreservingOrder (uint pos, uint count=1)
 Remove items from the vector while preserving the order of other items. More...
 
bool Include (const EngineIDMapping &item)
 Tests whether a item is present in the vector, and appends it to the end if not. More...
 
uint Length () const
 Get the number of items in the list. More...
 
const EngineIDMappingBegin () const
 Get the pointer to the first item (const) More...
 
EngineIDMappingBegin ()
 Get the pointer to the first item. More...
 
const EngineIDMappingEnd () const
 Get the pointer behind the last valid item (const) More...
 
EngineIDMappingEnd ()
 Get the pointer behind the last valid item. More...
 
const EngineIDMappingGet (uint index) const
 Get the pointer to item "number" (const) More...
 
EngineIDMappingGet (uint index)
 Get the pointer to item "number". More...
 
const EngineIDMappingoperator[] (uint index) const
 Get item "number" (const) More...
 
EngineIDMappingoperator[] (uint index)
 Get item "number". More...
 

Static Public Member Functions

static bool ResetToCurrentNewGRFConfig ()
 Tries to reset the engine mapping to match the current NewGRF configuration. More...
 

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 >
EngineIDMappingdata
 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

◆ GetID()

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

Looks up an EngineID in the EngineOverrideManager.

Parameters
typeVehicle type
grf_local_idThe local id in the newgrf
grfidThe 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 Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::index, and INVALID_ENGINE.

◆ ResetToCurrentNewGRFConfig()

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().


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