mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-20 00:02:55 +00:00
Fix counting padding for root struct even when root struct has no properties
This commit is contained in:
parent
f236d285b6
commit
2e5405deb5
@ -116,10 +116,14 @@ namespace sdd::def_scope_sequences
|
|||||||
if (newStructPtr->m_name == "root")
|
if (newStructPtr->m_name == "root")
|
||||||
{
|
{
|
||||||
state->m_current_struct_padding_offset = 64u;
|
state->m_current_struct_padding_offset = 64u;
|
||||||
|
state->m_current_struct_is_root = true;
|
||||||
state->m_current_def->m_root_type = CommonStructuredDataType(CommonStructuredDataTypeCategory::STRUCT, newStructIndex);
|
state->m_current_def->m_root_type = CommonStructuredDataType(CommonStructuredDataTypeCategory::STRUCT, newStructIndex);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
state->m_current_struct_is_root = false;
|
||||||
state->m_current_struct_padding_offset = 0;
|
state->m_current_struct_padding_offset = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -232,8 +232,13 @@ namespace sdd::struct_scope_sequences
|
|||||||
{
|
{
|
||||||
assert(state->m_current_struct != nullptr);
|
assert(state->m_current_struct != nullptr);
|
||||||
|
|
||||||
|
// Only include root struct offset of 8 byte when root struct is not empty
|
||||||
|
if (state->m_current_struct_is_root && state->m_current_struct->m_properties.empty())
|
||||||
|
state->m_current_struct_padding_offset -= 64u;
|
||||||
|
|
||||||
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8u) / 8;
|
state->m_current_struct->m_size_in_byte = utils::Align(state->m_current_struct_padding_offset, 8u) / 8;
|
||||||
state->m_current_struct_padding_offset = 0u;
|
state->m_current_struct_padding_offset = 0u;
|
||||||
|
state->m_current_struct_is_root = false;
|
||||||
state->m_current_struct = nullptr;
|
state->m_current_struct = nullptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -31,6 +31,7 @@ namespace sdd
|
|||||||
CommonStructuredDataEnum* m_current_enum;
|
CommonStructuredDataEnum* m_current_enum;
|
||||||
CommonStructuredDataStruct* m_current_struct;
|
CommonStructuredDataStruct* m_current_struct;
|
||||||
|
|
||||||
|
bool m_current_struct_is_root;
|
||||||
size_t m_current_struct_padding_offset;
|
size_t m_current_struct_padding_offset;
|
||||||
|
|
||||||
size_t m_checksum_override_value;
|
size_t m_checksum_override_value;
|
||||||
|
@ -41,11 +41,11 @@ class StructuredDataDefSizeCalculatorInternal
|
|||||||
ss << "Circular dependencies detected: ";
|
ss << "Circular dependencies detected: ";
|
||||||
|
|
||||||
auto foundDependencyChainStart = false;
|
auto foundDependencyChainStart = false;
|
||||||
for(const auto& type : m_type_stack)
|
for (const auto& type : m_type_stack)
|
||||||
{
|
{
|
||||||
if(foundDependencyChainStart)
|
if (foundDependencyChainStart)
|
||||||
{
|
{
|
||||||
if(type.m_category == CommonStructuredDataTypeCategory::STRUCT)
|
if (type.m_category == CommonStructuredDataTypeCategory::STRUCT)
|
||||||
{
|
{
|
||||||
assert(type.m_info.type_index < m_def.m_structs.size());
|
assert(type.m_info.type_index < m_def.m_structs.size());
|
||||||
ss << " -> " << m_def.m_structs[type.m_info.type_index]->m_name;
|
ss << " -> " << m_def.m_structs[type.m_info.type_index]->m_name;
|
||||||
@ -75,7 +75,7 @@ class StructuredDataDefSizeCalculatorInternal
|
|||||||
m_type_stack.emplace_back(CommonStructuredDataTypeCategory::STRUCT, index);
|
m_type_stack.emplace_back(CommonStructuredDataTypeCategory::STRUCT, index);
|
||||||
|
|
||||||
auto currentOffset = 0u;
|
auto currentOffset = 0u;
|
||||||
for(auto& property : _struct.m_properties)
|
for (auto& property : _struct.m_properties)
|
||||||
{
|
{
|
||||||
CalculateForType(property.m_type);
|
CalculateForType(property.m_type);
|
||||||
currentOffset = utils::Align(currentOffset, property.m_type.GetAlignmentInBits());
|
currentOffset = utils::Align(currentOffset, property.m_type.GetAlignmentInBits());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user