2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-03-07 05:23:02 +00:00

fix: filling union members that are not supposed to be written

* This causes some pointers to be partially overwritten when filling in the wrong order as well
This commit is contained in:
Jan Laupetin
2026-01-14 22:14:43 +00:00
parent 9f559fdcd0
commit 00546740e4
15 changed files with 72 additions and 69 deletions

View File

@@ -189,15 +189,15 @@ bool MemberComputations::IsInRuntimeBlock() const
return m_info->m_fast_file_block != nullptr && m_info->m_fast_file_block->m_type == FastFileBlockType::RUNTIME;
}
bool MemberComputations::IsFirstUsedMember() const
bool MemberComputations::IsFirstUsedMember(const bool includeLeafs) const
{
const auto parentUsedMembers = StructureComputations(m_info->m_parent).GetUsedMembers();
const auto parentUsedMembers = StructureComputations(m_info->m_parent).GetUsedMembers(includeLeafs);
return !parentUsedMembers.empty() && parentUsedMembers[0] == m_info;
}
bool MemberComputations::IsLastUsedMember() const
bool MemberComputations::IsLastUsedMember(const bool includeLeafs) const
{
const auto parentUsedMembers = StructureComputations(m_info->m_parent).GetUsedMembers();
const auto parentUsedMembers = StructureComputations(m_info->m_parent).GetUsedMembers(includeLeafs);
return !parentUsedMembers.empty() && parentUsedMembers[parentUsedMembers.size() - 1] == m_info;
}

View File

@@ -25,8 +25,8 @@ public:
[[nodiscard]] bool IsNotInDefaultNormalBlock() const;
[[nodiscard]] bool IsInTempBlock() const;
[[nodiscard]] bool IsInRuntimeBlock() const;
[[nodiscard]] bool IsFirstUsedMember() const;
[[nodiscard]] bool IsLastUsedMember() const;
[[nodiscard]] bool IsFirstUsedMember(bool includeLeafs) const;
[[nodiscard]] bool IsLastUsedMember(bool includeLeafs) const;
[[nodiscard]] bool HasDynamicArraySize() const;
[[nodiscard]] bool IsDynamicMember() const;
[[nodiscard]] bool IsAfterPartialLoad() const;

View File

@@ -38,7 +38,7 @@ bool StructureComputations::HasNonDynamicMember() const
return false;
}
std::vector<MemberInformation*> StructureComputations::GetUsedMembers() const
std::vector<MemberInformation*> StructureComputations::GetUsedMembers(const bool includeLeafs) const
{
std::vector<MemberInformation*> members;
@@ -54,7 +54,7 @@ std::vector<MemberInformation*> StructureComputations::GetUsedMembers() const
{
for (const auto& member : m_info->m_ordered_members)
{
if (!member->m_is_leaf && !MemberComputations(member.get()).ShouldIgnore())
if ((includeLeafs || !member->m_is_leaf) && !MemberComputations(member.get()).ShouldIgnore())
members.push_back(member.get());
}
}

View File

@@ -10,7 +10,7 @@ public:
[[nodiscard]] bool IsAsset() const;
[[nodiscard]] MemberInformation* GetDynamicMember() const;
[[nodiscard]] bool HasNonDynamicMember() const;
[[nodiscard]] std::vector<MemberInformation*> GetUsedMembers() const;
[[nodiscard]] std::vector<MemberInformation*> GetUsedMembers(bool includeLeafs) const;
[[nodiscard]] bool IsInTempBlock() const;
private: