OpenTTD Source 20260206-master-g4d4e37dbf1
EngineOverrideManager Struct Reference

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

#include <engine_base.h>

Public Member Functions

void ResetToDefaultMapping ()
 Initializes the EngineOverrideManager with the default engines.
EngineID GetID (VehicleType type, uint16_t grf_local_id, uint32_t grfid)
 Looks up an EngineID in the EngineOverrideManager.
EngineID UseUnreservedID (VehicleType type, uint16_t grf_local_id, uint32_t grfid, bool static_access)
 Look for an unreserved EngineID matching the local id, and reserve it if found.
void SetID (VehicleType type, uint16_t grf_local_id, uint32_t grfid, uint8_t substitute_id, EngineID engine)

Static Public Member Functions

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

Data Fields

std::array< std::vector< EngineIDMapping >, VEH_COMPANY_ENDmappings

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 reset in different cases.

Definition at line 227 of file engine_base.h.

Member Function Documentation

◆ GetID()

EngineID EngineOverrideManager::GetID ( VehicleType type,
uint16_t grf_local_id,
uint32_t 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 dynamic_engines is disabled, all newgrf share the same ID scope identified by INVALID_GRFID.
Returns
The engine ID if present, or EngineID::Invalid() if not.

Definition at line 533 of file engine.cpp.

◆ 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 588 of file engine.cpp.

References IsCompanyBuildableVehicleType(), and ReloadNewGRFData().

Referenced by CheckDynamicEngines(), ConResetEnginePool(), OnStartScenario(), and ResetLandscapeConfirmationCallback().

◆ ResetToDefaultMapping()

void EngineOverrideManager::ResetToDefaultMapping ( )

Initializes the EngineOverrideManager with the default engines.

Definition at line 512 of file engine.cpp.

References _engine_counts, VEH_AIRCRAFT, and VEH_TRAIN.

◆ SetID()

void EngineOverrideManager::SetID ( VehicleType type,
uint16_t grf_local_id,
uint32_t grfid,
uint8_t substitute_id,
EngineID engine )

Definition at line 571 of file engine.cpp.

◆ UseUnreservedID()

EngineID EngineOverrideManager::UseUnreservedID ( VehicleType type,
uint16_t grf_local_id,
uint32_t grfid,
bool static_access )

Look for an unreserved EngineID matching the local id, and reserve it if found.

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 dynamic_engines is disabled, all newgrf share the same ID scope identified by INVALID_GRFID.
static_accessWhether to actually reserve the EngineID.
Returns
The engine ID if present and now reserved, or EngineID::Invalid() if not.

Definition at line 552 of file engine.cpp.

References Slide().

Field Documentation

◆ mappings

std::array<std::vector<EngineIDMapping>, VEH_COMPANY_END> EngineOverrideManager::mappings

Definition at line 228 of file engine_base.h.


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