mirror of
				https://github.com/Laupetin/OpenAssetTools.git
				synced 2025-10-30 18:17:15 +00:00 
			
		
		
		
	Fix counting padding for root struct even when root struct has no properties
This commit is contained in:
		| @@ -116,10 +116,14 @@ namespace sdd::def_scope_sequences | ||||
|             if (newStructPtr->m_name == "root") | ||||
|             { | ||||
|                 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); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 state->m_current_struct_is_root = false; | ||||
|                 state->m_current_struct_padding_offset = 0; | ||||
|             } | ||||
|         } | ||||
|     }; | ||||
|  | ||||
|   | ||||
| @@ -232,8 +232,13 @@ namespace sdd::struct_scope_sequences | ||||
|         { | ||||
|             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_padding_offset = 0u; | ||||
|             state->m_current_struct_is_root = false; | ||||
|             state->m_current_struct = nullptr; | ||||
|         } | ||||
|     }; | ||||
|   | ||||
| @@ -31,6 +31,7 @@ namespace sdd | ||||
|         CommonStructuredDataEnum* m_current_enum; | ||||
|         CommonStructuredDataStruct* m_current_struct; | ||||
|  | ||||
|         bool m_current_struct_is_root; | ||||
|         size_t m_current_struct_padding_offset; | ||||
|  | ||||
|         size_t m_checksum_override_value; | ||||
|   | ||||
| @@ -41,11 +41,11 @@ class StructuredDataDefSizeCalculatorInternal | ||||
|         ss << "Circular dependencies detected: "; | ||||
|  | ||||
|         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()); | ||||
|                     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); | ||||
|  | ||||
|         auto currentOffset = 0u; | ||||
|         for(auto& property : _struct.m_properties) | ||||
|         for (auto& property : _struct.m_properties) | ||||
|         { | ||||
|             CalculateForType(property.m_type); | ||||
|             currentOffset = utils::Align(currentOffset, property.m_type.GetAlignmentInBits()); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user