* 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
| 527 | * @return The engine ID if present, or EngineID::Invalid() if not. |
| 528 | */ |
| 529 | EngineID 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. |
no test coverage detected