* 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.
| 294 | * properties of an existing engine. |
| 295 | */ |
| 296 | EngineID 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 |
no test coverage detected