diff --git a/libespm/include/libespm/CombineBrowser.h b/libespm/include/libespm/CombineBrowser.h index 063990f6a0..8393d8d49e 100644 --- a/libespm/include/libespm/CombineBrowser.h +++ b/libespm/include/libespm/CombineBrowser.h @@ -27,8 +27,7 @@ class CombineBrowser std::vector*> GetRecordsByType( const char* type) const; - const std::vector GetDistinctRecordsByType( - const char* type) const; + std::vector GetDistinctRecordsByType(const char* type) const; std::vector*> GetRecordsAtPos( uint32_t cellOrWorld, int16_t cellX, int16_t cellY) const; diff --git a/libespm/src/CombineBrowser.cpp b/libespm/src/CombineBrowser.cpp index 9fa345f86d..757ddf8645 100644 --- a/libespm/src/CombineBrowser.cpp +++ b/libespm/src/CombineBrowser.cpp @@ -84,26 +84,25 @@ CombineBrowser::GetRecordsByType(const char* type) const return res; } -const std::vector -CombineBrowser::GetDistinctRecordsByType(const char* type) const +std::vector CombineBrowser::GetDistinctRecordsByType( + const char* type) const { if (pImpl->numSources == 0) { return {}; } spp::sparse_hash_set formSet; - std::vector result; + std::vector result; for (size_t i = pImpl->numSources - 1; i != static_cast(-1); --i) { const auto& records = pImpl->sources[i].br->GetRecordsByType(type); formSet.reserve(records.size()); result.reserve(records.size()); for (auto record : records) { - if (formSet - .insert( - utils::GetMappedId(record->GetId(), *pImpl->sources[i].toComb)) - .second) { - result.push_back(record); + auto mappedId = + utils::GetMappedId(record->GetId(), *pImpl->sources[i].toComb); + if (formSet.insert(mappedId).second) { + result.push_back(LookupResult(this, record, static_cast(i))); } } }