2017-10-26 05:37:46 +00:00
|
|
|
#include "MP1OriginalIDs.hpp"
|
|
|
|
#include "CToken.hpp"
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2017-10-26 05:37:46 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
MP1OriginalIDs::MP1OriginalIDs(CInputStream& in) {
|
|
|
|
u32 count = in.readUint32Big();
|
|
|
|
m_origToNew.reserve(count);
|
|
|
|
for (u32 i = 0; i < count; ++i) {
|
|
|
|
CAssetId a = in.readUint32Big();
|
|
|
|
CAssetId b = in.readUint32Big();
|
|
|
|
m_origToNew.push_back(std::make_pair(a, b));
|
|
|
|
}
|
|
|
|
m_newToOrig.reserve(count);
|
|
|
|
for (u32 i = 0; i < count; ++i) {
|
|
|
|
CAssetId a = in.readUint32Big();
|
|
|
|
CAssetId b = in.readUint32Big();
|
|
|
|
m_newToOrig.push_back(std::make_pair(a, b));
|
|
|
|
}
|
2017-10-26 05:37:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAssetId MP1OriginalIDs::TranslateOriginalToNew(CAssetId id) const {
|
|
|
|
auto search =
|
|
|
|
rstl::binary_find(m_origToNew.cbegin(), m_origToNew.cend(), id, [](const auto& id) { return id.first; });
|
|
|
|
if (search == m_origToNew.cend())
|
|
|
|
return {};
|
|
|
|
return search->second;
|
2017-10-26 05:37:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAssetId MP1OriginalIDs::TranslateNewToOriginal(CAssetId id) const {
|
|
|
|
auto search =
|
|
|
|
rstl::binary_find(m_newToOrig.cbegin(), m_newToOrig.cend(), id, [](const auto& id) { return id.first; });
|
|
|
|
if (search == m_newToOrig.cend())
|
|
|
|
return {};
|
|
|
|
return search->second;
|
2017-10-26 05:37:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CFactoryFnReturn FMP1OriginalIDsFactory(const SObjectTag& tag, CInputStream& in, const CVParamTransfer& param,
|
|
|
|
CObjectReference* selfRef) {
|
|
|
|
return TToken<MP1OriginalIDs>::GetIObjObjectFor(std::make_unique<MP1OriginalIDs>(in));
|
2017-10-26 05:37:46 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|