MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetID

Method GetID

src/engine.cpp:529–536  ·  view source on GitHub ↗

* Looks up an EngineID in the EngineOverrideManager * @param type Vehicle type * @param grf_local_id The local id in the newgrf * @param 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 dynamic_engines is disabled, all newgrf share the same ID scop

Source from the content-addressed store, hash-verified

527 * @return The engine ID if present, or EngineID::Invalid() if not.
528 */
529EngineID EngineOverrideManager::GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid)
530{
531 const auto &map = this->mappings[type];
532 const auto key = EngineIDMapping::Key(grfid, grf_local_id);
533 auto it = std::ranges::lower_bound(map, key, std::less{}, EngineIDMappingKeyProjection{});
534 if (it == std::end(map) || it->Key() != key) return EngineID::Invalid();
535 return it->engine;
536}
537
538/**
539 * Look for an unreserved EngineID matching the local id, and reserve it if found.

Callers 10

GetNewEngineFunction · 0.45
GetNewEngineIDFunction · 0.45
GetVariableMethod · 0.45
MapNewGRFIndustryTypeFunction · 0.45
ResolveNewGRFIDMethod · 0.45
ResolveNewGRFIDMethod · 0.45
IndustriesChangeInfoFunction · 0.45
AirportChangeInfoFunction · 0.45

Calls 3

InvalidFunction · 0.85
KeyMethod · 0.80
endFunction · 0.50

Tested by

no test coverage detected