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

Function GetNewEngineID

src/newgrf.cpp:296–307  ·  view source on GitHub ↗

* Return the ID of a new engine * @param file The NewGRF file providing the engine. * @param type The Vehicle type. * @param internal_id NewGRF-internal ID of the engine. * @return The new EngineID. * @note depending on the dynamic_engine setting and a possible override * property the grfID may be unique or overwriting or partially re-defining * properties of an existing engine.

Source from the content-addressed store, hash-verified

294 * properties of an existing engine.
295 */
296EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16_t internal_id)
297{
298 uint32_t scope_grfid = INVALID_GRFID; // If not using dynamic_engines, all newgrfs share their ID range
299 if (_settings_game.vehicle.dynamic_engines) {
300 scope_grfid = file->grfid;
301 if (auto it = _grf_id_overrides.find(file->grfid); it != std::end(_grf_id_overrides)) {
302 scope_grfid = it->second;
303 }
304 }
305
306 return _engine_mngr.GetID(type, internal_id, scope_grfid);
307}
308
309
310

Callers 2

FinaliseEngineArrayFunction · 0.85
GetNextArticulatedPartFunction · 0.85

Calls 3

endFunction · 0.50
findMethod · 0.45
GetIDMethod · 0.45

Tested by

no test coverage detected