mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-16 00:42:45 +01:00
Codechange: Don't inherit EngineOverrideManager from std::vector.
Inheriting from std::vector means some operations are needlessly complex, and shouldn't really be done anyway.
This commit is contained in:
committed by
Peter Nelson
parent
e73d6fcaac
commit
bc2513975f
@@ -509,14 +509,10 @@ bool Engine::IsVariantHidden(CompanyID c) const
|
||||
*/
|
||||
void EngineOverrideManager::ResetToDefaultMapping()
|
||||
{
|
||||
this->clear();
|
||||
this->mappings.clear();
|
||||
for (VehicleType type = VEH_TRAIN; type <= VEH_AIRCRAFT; type++) {
|
||||
for (uint internal_id = 0; internal_id < _engine_counts[type]; internal_id++) {
|
||||
EngineIDMapping &eid = this->emplace_back();
|
||||
eid.type = type;
|
||||
eid.grfid = INVALID_GRFID;
|
||||
eid.internal_id = internal_id;
|
||||
eid.substitute_id = internal_id;
|
||||
this->mappings.emplace_back(INVALID_GRFID, internal_id, type, internal_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,7 +529,7 @@ void EngineOverrideManager::ResetToDefaultMapping()
|
||||
EngineID EngineOverrideManager::GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid)
|
||||
{
|
||||
EngineID index = 0;
|
||||
for (const EngineIDMapping &eid : *this) {
|
||||
for (const EngineIDMapping &eid : this->mappings) {
|
||||
if (eid.type == type && eid.grfid == grfid && eid.internal_id == grf_local_id) {
|
||||
return index;
|
||||
}
|
||||
@@ -568,9 +564,9 @@ void SetupEngines()
|
||||
CloseWindowByClass(WC_ENGINE_PREVIEW);
|
||||
_engine_pool.CleanPool();
|
||||
|
||||
assert(_engine_mngr.size() >= _engine_mngr.NUM_DEFAULT_ENGINES);
|
||||
assert(_engine_mngr.mappings.size() >= EngineOverrideManager::NUM_DEFAULT_ENGINES);
|
||||
[[maybe_unused]] uint index = 0;
|
||||
for (const EngineIDMapping &eid : _engine_mngr) {
|
||||
for (const EngineIDMapping &eid : _engine_mngr.mappings) {
|
||||
/* Assert is safe; there won't be more than 256 original vehicles
|
||||
* in any case, and we just cleaned the pool. */
|
||||
assert(Engine::CanAllocateItem());
|
||||
|
||||
Reference in New Issue
Block a user