diff --git a/src/Common/Game/IW3/IW3_Assets.h b/src/Common/Game/IW3/IW3_Assets.h index 8c66b817..f0f21f0b 100644 --- a/src/Common/Game/IW3/IW3_Assets.h +++ b/src/Common/Game/IW3/IW3_Assets.h @@ -55,6 +55,7 @@ namespace IW3 struct StringTable; typedef unsigned short ScriptString; + typedef tdef_align32(16) char raw_byte16; union XAssetHeader { @@ -2382,7 +2383,7 @@ namespace IW3 unsigned int dynEntClientWordCount[2]; unsigned int dynEntClientCount[2]; unsigned int* dynEntCellBits[2]; - char* dynEntVisData[2][3]; + raw_byte16* dynEntVisData[2][3]; }; struct GfxWorldStreamInfo diff --git a/src/Common/Game/T5/T5_Assets.h b/src/Common/Game/T5/T5_Assets.h index bc64f873..c8f9db37 100644 --- a/src/Common/Game/T5/T5_Assets.h +++ b/src/Common/Game/T5/T5_Assets.h @@ -3124,7 +3124,7 @@ namespace T5 unsigned int dynEntClientWordCount[2]; unsigned int dynEntClientCount[2]; unsigned int* dynEntCellBits[2]; - char* dynEntVisData[2][3]; + raw_byte16* dynEntVisData[2][3]; }; struct GfxWorldLodChain diff --git a/src/Common/Game/T6/T6_Assets.h b/src/Common/Game/T6/T6_Assets.h index d87251cd..a069ae35 100644 --- a/src/Common/Game/T6/T6_Assets.h +++ b/src/Common/Game/T6/T6_Assets.h @@ -1296,8 +1296,6 @@ namespace T6 vec3_t sunFxPosition; }; - typedef tdef_align32(4) GfxDrawSurf GfxDrawSurf_align4; - struct GfxWorldDpvsStatic { unsigned int smodelCount; @@ -1320,7 +1318,7 @@ namespace T6 GfxStaticModelInst* smodelInsts; GfxSurface* surfaces; GfxStaticModelDrawInst* smodelDrawInsts; - GfxDrawSurf_align4* surfaceMaterials; + GfxDrawSurf* surfaceMaterials; raw_byte128* surfaceCastsSunShadow; raw_byte128* surfaceCastsShadow; raw_byte128* smodelCastsShadow; diff --git a/src/ZoneCode/Game/IW3/XAssets/GfxWorld.txt b/src/ZoneCode/Game/IW3/XAssets/GfxWorld.txt index 8bb1c933..38111884 100644 --- a/src/ZoneCode/Game/IW3/XAssets/GfxWorld.txt +++ b/src/ZoneCode/Game/IW3/XAssets/GfxWorld.txt @@ -109,6 +109,7 @@ set count cullGroups GfxWorld::cullGroupCount; set count smodelDrawInsts smodelCount; set block surfaceMaterials XFILE_BLOCK_RUNTIME; set count surfaceMaterials staticSurfaceCount; +set allocalign surfaceMaterials 4; set block surfaceCastsSunShadow XFILE_BLOCK_RUNTIME; set count surfaceCastsSunShadow surfaceVisDataCount; diff --git a/src/ZoneCode/Game/IW3/XAssets/Material.txt b/src/ZoneCode/Game/IW3/XAssets/Material.txt index d4ef7c6e..66200379 100644 --- a/src/ZoneCode/Game/IW3/XAssets/Material.txt +++ b/src/ZoneCode/Game/IW3/XAssets/Material.txt @@ -3,6 +3,7 @@ // ========================================= use Material; set block XFILE_BLOCK_TEMP; +set allocalign Material 4; set string info::name; set reusable textureTable; set count textureTable textureCount; diff --git a/src/ZoneCode/Game/IW4/XAssets/Material.txt b/src/ZoneCode/Game/IW4/XAssets/Material.txt index d4ef7c6e..66200379 100644 --- a/src/ZoneCode/Game/IW4/XAssets/Material.txt +++ b/src/ZoneCode/Game/IW4/XAssets/Material.txt @@ -3,6 +3,7 @@ // ========================================= use Material; set block XFILE_BLOCK_TEMP; +set allocalign Material 4; set string info::name; set reusable textureTable; set count textureTable textureCount; diff --git a/src/ZoneCode/Game/IW5/XAssets/Material.txt b/src/ZoneCode/Game/IW5/XAssets/Material.txt index bc21dd4c..14f4640c 100644 --- a/src/ZoneCode/Game/IW5/XAssets/Material.txt +++ b/src/ZoneCode/Game/IW5/XAssets/Material.txt @@ -3,6 +3,7 @@ // ========================================= use Material; set block XFILE_BLOCK_TEMP; +set allocalign Material 4; set string info::name; set reusable textureTable; set count textureTable textureCount; diff --git a/src/ZoneCode/Game/T5/XAssets/GfxWorld.txt b/src/ZoneCode/Game/T5/XAssets/GfxWorld.txt index 484f77cf..c2eded82 100644 --- a/src/ZoneCode/Game/T5/XAssets/GfxWorld.txt +++ b/src/ZoneCode/Game/T5/XAssets/GfxWorld.txt @@ -137,6 +137,7 @@ set count cullGroups GfxWorld::cullGroupCount; set count smodelDrawInsts smodelCount; set block surfaceMaterials XFILE_BLOCK_RUNTIME; set count surfaceMaterials staticSurfaceCount; +set allocalign surfaceMaterials 4; set block surfaceCastsSunShadow XFILE_BLOCK_RUNTIME; set count surfaceCastsSunShadow surfaceVisDataCount; diff --git a/src/ZoneCode/Game/T5/XAssets/Material.txt b/src/ZoneCode/Game/T5/XAssets/Material.txt index d4ef7c6e..66200379 100644 --- a/src/ZoneCode/Game/T5/XAssets/Material.txt +++ b/src/ZoneCode/Game/T5/XAssets/Material.txt @@ -3,6 +3,7 @@ // ========================================= use Material; set block XFILE_BLOCK_TEMP; +set allocalign Material 4; set string info::name; set reusable textureTable; set count textureTable textureCount; diff --git a/src/ZoneCode/Game/T6/XAssets/GfxWorld.txt b/src/ZoneCode/Game/T6/XAssets/GfxWorld.txt index f5b70587..f5ca5830 100644 --- a/src/ZoneCode/Game/T6/XAssets/GfxWorld.txt +++ b/src/ZoneCode/Game/T6/XAssets/GfxWorld.txt @@ -162,6 +162,7 @@ set count surfaces GfxWorld::surfaceCount; set count smodelDrawInsts smodelCount; set block surfaceMaterials XFILE_BLOCK_RUNTIME_VIRTUAL; set count surfaceMaterials staticSurfaceCount; +set allocalign surfaceMaterials 4; reorder: smodelVisData surfaceVisData diff --git a/src/ZoneCode/Game/T6/XAssets/Material.txt b/src/ZoneCode/Game/T6/XAssets/Material.txt index 64b96ca3..ee10d30f 100644 --- a/src/ZoneCode/Game/T6/XAssets/Material.txt +++ b/src/ZoneCode/Game/T6/XAssets/Material.txt @@ -3,6 +3,7 @@ // ========================================= use Material; set block XFILE_BLOCK_TEMP; +set allocalign Material 4; set string info::name; set reusable textureTable; set count textureTable textureCount; diff --git a/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.cpp b/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.cpp index ea716b06..1cc3df56 100644 --- a/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.cpp +++ b/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.cpp @@ -7,10 +7,7 @@ DefinitionWithMembers::DefinitionWithMembers(std::string _namespace, std::string m_flags(0), m_size(0), m_alignment(0), - m_has_alignment_override(false), - m_anonymous(false), - m_pack(pack), - m_alignment_override(0) + m_pack(pack) { } @@ -23,8 +20,6 @@ unsigned DefinitionWithMembers::GetAlignment() const bool DefinitionWithMembers::GetForceAlignment() const { - assert(m_flags & FLAG_FIELDS_CALCULATED); - return m_flags & FLAG_ALIGNMENT_FORCED; } @@ -34,3 +29,8 @@ unsigned DefinitionWithMembers::GetSize() const return m_size; } + +bool DefinitionWithMembers::IsAnonymous() const +{ + return m_flags & FLAG_ANONYMOUS; +} diff --git a/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.h b/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.h index 56ae9c0a..966a7a6d 100644 --- a/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.h +++ b/src/ZoneCodeGeneratorLib/Domain/Definition/DefinitionWithMembers.h @@ -12,22 +12,19 @@ public: static constexpr int FLAG_FIELDS_CALCULATED = 1 << 0; static constexpr int FLAG_FIELDS_CALCULATING = 1 << 1; static constexpr int FLAG_ALIGNMENT_FORCED = 1 << 2; + static constexpr int FLAG_ANONYMOUS = 1 << 3; DefinitionWithMembers(std::string _namespace, std::string name, unsigned pack); [[nodiscard]] unsigned GetAlignment() const override; [[nodiscard]] bool GetForceAlignment() const override; [[nodiscard]] unsigned GetSize() const override; + [[nodiscard]] bool IsAnonymous() const; unsigned m_flags; unsigned m_size; unsigned m_alignment; - - bool m_has_alignment_override; - bool m_anonymous; - - const unsigned m_pack; - unsigned m_alignment_override; + unsigned m_pack; std::vector> m_members; }; diff --git a/src/ZoneCodeGeneratorLib/Domain/Information/StructureInformation.h b/src/ZoneCodeGeneratorLib/Domain/Information/StructureInformation.h index f3518c8f..bc15daec 100644 --- a/src/ZoneCodeGeneratorLib/Domain/Information/StructureInformation.h +++ b/src/ZoneCodeGeneratorLib/Domain/Information/StructureInformation.h @@ -21,6 +21,7 @@ public: TypeInformation* m_type_info; std::string m_asset_name; + std::unique_ptr m_alloc_alignment; std::vector m_usages; std::vector> m_ordered_members; diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp index 1b851e06..0c2455b5 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/AssetStructTestsTemplate.cpp @@ -42,7 +42,7 @@ namespace for (const auto* structure : m_env.m_used_structures) { StructureComputations computations(structure->m_info); - if (!structure->m_info->m_definition->m_anonymous && !computations.IsAsset() && structure->m_info->m_has_matching_cross_platform_structure) + if (!structure->m_info->m_definition->IsAnonymous() && !computations.IsAsset() && structure->m_info->m_has_matching_cross_platform_structure) TestMethod(structure->m_info); } diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.cpp index dca825c9..b2b266f8 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.cpp @@ -256,6 +256,14 @@ void BaseTemplate::MakeEvaluationInternal(const IEvaluation* evaluation, std::os MakeOperandDynamic(dynamic_cast(evaluation), str); } +std::string BaseTemplate::MakeAllocAlignment(const StructureInformation& info) +{ + if (info.m_alloc_alignment) + return MakeEvaluation(info.m_alloc_alignment.get()); + + return std::to_string(info.m_definition->GetAlignment()); +} + std::string BaseTemplate::MakeEvaluation(const IEvaluation* evaluation) { std::ostringstream str; diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.h b/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.h index d35a76fc..9eeb3205 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.h +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/Internal/BaseTemplate.h @@ -33,6 +33,7 @@ protected: static std::string MakeArrayIndices(const DeclarationModifierComputations& modifierComputations); static std::string MakeCustomActionCall(const CustomAction* action); static std::string MakeArrayCount(const ArrayDeclarationModifier* arrayModifier); + static std::string MakeAllocAlignment(const StructureInformation& info); static std::string MakeEvaluation(const IEvaluation* evaluation); static bool ShouldGenerateFillMethod(const RenderingUsedType& type); diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp index 46a3bd27..3442e103 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneLoadTemplate.cpp @@ -138,7 +138,7 @@ namespace // Variable Declarations: type varType; for (const auto* type : m_env.m_used_types) { - if (type->m_info && !type->m_info->m_definition->m_anonymous + if (type->m_info && !type->m_info->m_definition->IsAnonymous() && (!type->m_info->m_is_leaf || !type->m_info->m_has_matching_cross_platform_structure) && !StructureComputations(type->m_info).IsAsset()) { LINE(VariableDecl(type->m_type)) @@ -345,7 +345,7 @@ namespace for (const auto* type : m_env.m_used_types) { - if (type->m_info && !type->m_info->m_definition->m_anonymous + if (type->m_info && !type->m_info->m_definition->IsAnonymous() && (!type->m_info->m_is_leaf || !type->m_info->m_has_matching_cross_platform_structure) && !StructureComputations(type->m_info).IsAsset()) { PrintVariableInitialization(type->m_type); @@ -480,7 +480,7 @@ namespace const DeclarationModifierComputations& modifier, const size_t nestedBaseOffset) { - const auto hasAnonymousType = memberInfo.m_type && memberInfo.m_type->m_definition->m_anonymous; + const auto hasAnonymousType = memberInfo.m_type && memberInfo.m_type->m_definition->IsAnonymous(); if (!hasAnonymousType) { @@ -888,10 +888,12 @@ namespace void PrintLoadPtrArrayMethod_Loading(const DataDefinition* def, const StructureInformation* info) const { + const auto alignment = info && def == info->m_definition ? MakeAllocAlignment(*info) : std::to_string(def->GetAlignment()); if (info && !info->m_has_matching_cross_platform_structure && StructureComputations(info).GetDynamicMember()) { + assert(def == info->m_definition); LINE("// Alloc first for alignment, then proceed to read as game does") - LINEF("m_stream.Alloc({0});", def->GetAlignment()) + LINEF("m_stream.Alloc({0});", alignment) LINEF("const auto allocSize = LoadDynamicFill_{0}(m_stream.LoadWithFill(0));", MakeSafeTypeName(def)) LINEF("*{0} = static_cast<{1}*>(m_stream.AllocOutOfBlock(0, allocSize));", MakeTypePtrVarName(def), def->GetFullName()) } @@ -901,7 +903,7 @@ namespace MakeTypePtrVarName(def), m_env.m_word_size_mismatch ? "AllocOutOfBlock" : "Alloc", def->GetFullName(), - def->GetAlignment()) + alignment) } if (info && !info->m_is_leaf) @@ -1989,7 +1991,7 @@ namespace MakeTypePtrVarName(info->m_definition), m_env.m_word_size_mismatch ? "AllocOutOfBlock" : "Alloc", info->m_definition->GetFullName(), - info->m_definition->GetAlignment()) + MakeAllocAlignment(*info)) if (inTemp) { diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp index 9c79ad0a..ac6f0b32 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneMarkTemplate.cpp @@ -114,7 +114,7 @@ namespace // Variable Declarations: type varType; for (const auto* type : m_env.m_used_types) { - if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset()) + if (type->m_info && !type->m_info->m_definition->IsAnonymous() && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset()) { LINE(VariableDecl(type->m_type)) } @@ -267,7 +267,7 @@ namespace for (const auto* type : m_env.m_used_types) { - if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset()) + if (type->m_info && !type->m_info->m_definition->IsAnonymous() && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset()) { PrintVariableInitialization(type->m_type); } diff --git a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp index 3a6d1c82..fd484bb4 100644 --- a/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp +++ b/src/ZoneCodeGeneratorLib/Generating/Templates/ZoneWriteTemplate.cpp @@ -124,7 +124,7 @@ namespace // Variable Declarations: type varType; for (const auto* type : m_env.m_used_types) { - if (type->m_info && !type->m_info->m_definition->m_anonymous + if (type->m_info && !type->m_info->m_definition->IsAnonymous() && (!type->m_info->m_is_leaf || !type->m_info->m_has_matching_cross_platform_structure) && !StructureComputations(type->m_info).IsAsset()) LINE(VariableDecl(type->m_type)) } @@ -138,7 +138,7 @@ namespace for (const auto* type : m_env.m_used_types) { - if (type->m_info && !type->m_info->m_definition->m_anonymous && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset()) + if (type->m_info && !type->m_info->m_definition->IsAnonymous() && !type->m_info->m_is_leaf && !StructureComputations(type->m_info).IsAsset()) LINE(WrittenVariableDecl(type->m_type)) } for (const auto* type : m_env.m_used_types) @@ -370,7 +370,7 @@ namespace for (const auto* type : m_env.m_used_types) { - if (type->m_info && !type->m_info->m_definition->m_anonymous + if (type->m_info && !type->m_info->m_definition->IsAnonymous() && (!type->m_info->m_is_leaf || !type->m_info->m_has_matching_cross_platform_structure) && !StructureComputations(type->m_info).IsAsset()) PrintVariableInitialization(type->m_type); } @@ -1201,7 +1201,7 @@ namespace LINE("{") m_intendation++; - LINEF("m_stream->Align({0});", info->m_definition->GetAlignment()) + LINEF("m_stream->Align({0});", MakeAllocAlignment(*info)) LINEF("m_stream->ReusableAddOffset(*{0});", MakeTypePtrVarName(info->m_definition)) LINE("") if (!info->m_is_leaf) @@ -1282,7 +1282,7 @@ namespace const DeclarationModifierComputations& modifier, const size_t nestedBaseOffset) { - const auto hasAnonymousType = memberInfo.m_type && memberInfo.m_type->m_definition->m_anonymous; + const auto hasAnonymousType = memberInfo.m_type && memberInfo.m_type->m_definition->IsAnonymous(); if (!hasAnonymousType) { @@ -1478,7 +1478,8 @@ namespace void PrintWritePtrArrayMethod_Loading(const DataDefinition* def, const StructureInformation* info, const bool reusable) const { - LINEF("m_stream->Align({0});", def->GetAlignment()) + const auto alignment = info && def == info->m_definition ? MakeAllocAlignment(*info) : std::to_string(def->GetAlignment()); + LINEF("m_stream->Align({0});", alignment) if (reusable) { diff --git a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAllocAlign.cpp b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAllocAlign.cpp index 4047222b..710c6aa6 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAllocAlign.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Commands/Sequence/SequenceAllocAlign.cpp @@ -31,9 +31,9 @@ void SequenceAllocAlign::ProcessMatch(CommandsParserState* state, SequenceResult if (!state->GetTypenameAndMembersFromTypename(typeNameToken.TypeNameValue(), type, memberChain)) throw ParsingException(typeNameToken.GetPos(), "Unknown type"); - if (memberChain.empty()) - throw ParsingException(typeNameToken.GetPos(), "Need to specify a member"); - auto allocAlignEvaluation = CommandsCommonMatchers::ProcessEvaluation(state, result, type); - memberChain.back()->m_alloc_alignment = std::move(allocAlignEvaluation); + if (memberChain.empty()) + type->m_alloc_alignment = std::move(allocAlignEvaluation); + else + memberChain.back()->m_alloc_alignment = std::move(allocAlignEvaluation); } diff --git a/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockStruct.cpp b/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockStruct.cpp index 90ca7e6c..b911206c 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockStruct.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockStruct.cpp @@ -61,15 +61,15 @@ void HeaderBlockStruct::OnClose(HeaderParserState* state) m_struct_definition = structDefinition.get(); if (m_is_anonymous) - structDefinition->m_anonymous = true; + structDefinition->m_flags |= DefinitionWithMembers::FLAG_ANONYMOUS; for (auto& member : m_members) structDefinition->m_members.emplace_back(std::move(member)); if (m_has_custom_align) { - structDefinition->m_alignment_override = static_cast(m_custom_alignment); - structDefinition->m_has_alignment_override = true; + structDefinition->m_alignment = static_cast(m_custom_alignment); + structDefinition->m_flags |= DefinitionWithMembers::FLAG_ALIGNMENT_FORCED; } state->AddDataType(std::move(structDefinition)); diff --git a/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockUnion.cpp b/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockUnion.cpp index 13767f26..c2c649a2 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockUnion.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/Header/Block/HeaderBlockUnion.cpp @@ -61,15 +61,15 @@ void HeaderBlockUnion::OnClose(HeaderParserState* state) m_union_definition = unionDefinition.get(); if (m_is_anonymous) - unionDefinition->m_anonymous = true; + unionDefinition->m_flags |= DefinitionWithMembers::FLAG_ANONYMOUS; for (auto& member : m_members) unionDefinition->m_members.emplace_back(std::move(member)); if (m_has_custom_align) { - unionDefinition->m_alignment_override = static_cast(m_custom_alignment); - unionDefinition->m_has_alignment_override = true; + unionDefinition->m_alignment = static_cast(m_custom_alignment); + unionDefinition->m_flags |= DefinitionWithMembers::FLAG_ALIGNMENT_FORCED; } state->AddDataType(std::move(unionDefinition)); diff --git a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp index f67fbf43..e2677ddc 100644 --- a/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp +++ b/src/ZoneCodeGeneratorLib/Parsing/PostProcessing/CalculateSizeAndAlignPostProcessor.cpp @@ -4,6 +4,7 @@ #include "Utils/Alignment.h" #include "Utils/Logging/Log.h" +#include #include #include #include @@ -43,12 +44,7 @@ namespace bool CalculateAlign(IDataRepository* repository, DefinitionWithMembers* definition) { - if (definition->m_has_alignment_override) - { - definition->m_flags |= DefinitionWithMembers::FLAG_ALIGNMENT_FORCED; - definition->m_alignment = definition->m_alignment_override; - } - else + if (!definition->GetForceAlignment()) { definition->m_alignment = 0; for (const auto& member : definition->m_members) @@ -57,8 +53,7 @@ namespace return false; const auto memberAlignment = member->GetAlignment(); - if (memberAlignment > definition->m_alignment) - definition->m_alignment = memberAlignment; + definition->m_alignment = std::max(memberAlignment, definition->m_alignment); } }