mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-11 07:18:11 -05:00
fix: make sure kvps are in a deterministic order
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
#include "KeyValuePairsCreator.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <ranges>
|
||||
|
||||
CommonKeyValuePair::CommonKeyValuePair(std::string keyStr, std::string value)
|
||||
: m_key_str(std::move(keyStr)),
|
||||
@ -49,6 +51,23 @@ void KeyValuePairsCreator::Finalize(const ZoneDefinition& zoneDefinition)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::ranges::sort(m_key_value_pairs,
|
||||
[](const CommonKeyValuePair& v0, const CommonKeyValuePair& v1)
|
||||
{
|
||||
if (v0.m_key_str.has_value())
|
||||
{
|
||||
if (!v1.m_key_str.has_value())
|
||||
return true;
|
||||
|
||||
return *v0.m_key_str < *v1.m_key_str;
|
||||
}
|
||||
|
||||
if (!v1.m_key_hash.has_value())
|
||||
return false;
|
||||
|
||||
return *v0.m_key_hash < *v1.m_key_hash;
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<CommonKeyValuePair> KeyValuePairsCreator::GetFinalKeyValuePairs()
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
std::string m_value;
|
||||
};
|
||||
|
||||
class KeyValuePairsCreator : public IZoneAssetCreationState
|
||||
class KeyValuePairsCreator final : public IZoneAssetCreationState
|
||||
{
|
||||
public:
|
||||
void AddKeyValuePair(CommonKeyValuePair keyValuePair);
|
||||
|
Reference in New Issue
Block a user