From 4bb8120d775beb12bb6c4aa0c13571637d7f749b Mon Sep 17 00:00:00 2001 From: Jan Date: Tue, 3 Jun 2025 22:01:43 +0100 Subject: [PATCH] fix: fill structs in runtime block that are not matching structure --- .../Generating/Templates/ZoneLoadTemplate.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp index 94f373f6..24c7d4a2 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp @@ -1129,7 +1129,7 @@ namespace } } - void LoadMember_ArrayPointer(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier) const + void LoadMember_ArrayPointer(const StructureInformation* info, const MemberInformation* member, const DeclarationModifierComputations& modifier) { const MemberComputations computations(member); if (member->m_type && !member->m_type->m_is_leaf && !computations.IsInRuntimeBlock()) @@ -1151,6 +1151,20 @@ namespace LINE(MakeCustomActionCall(member->m_post_load_action.get())) } } + else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure && computations.IsInRuntimeBlock()) + { + LINEF("const auto runtimeArraySize = static_cast({0});", MakeEvaluation(modifier.GetArrayPointerCountEvaluation())) + LINEF("const auto runtimeFill = m_stream.LoadWithFill({0} * runtimeArraySize);", member->m_member->m_type_declaration->m_type->GetSize()) + LINE("for (auto i = 0uz; i < runtimeArraySize; i++)") + LINE("{") + m_intendation++; + LINEF("{0} = &{1}[i];", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier)) + LINEF("FillStruct_{0}(runtimeFill.AtOffset(i * {1}));", + MakeSafeTypeName(member->m_member->m_type_declaration->m_type), + member->m_member->m_type_declaration->m_type->GetSize()) + m_intendation--; + LINE("}") + } else { LINEF("m_stream.Load<{0}{1}>({2}, {3});", @@ -1310,6 +1324,13 @@ namespace LINE(MakeCustomActionCall(member->m_post_load_action.get())) } } + else if (member->m_type && !member->m_type->m_has_matching_cross_platform_structure && computations.IsInRuntimeBlock()) + { + LINEF("{0} = {1};", MakeTypeVarName(member->m_member->m_type_declaration->m_type), MakeMemberAccess(info, member, modifier)) + LINEF("FillStruct_{0}(m_stream.LoadWithFill({1}));", + MakeSafeTypeName(member->m_member->m_type_declaration->m_type), + member->m_member->m_type_declaration->m_type->GetSize()) + } else { LINEF("m_stream.Load<{0}{1}>({2});",