mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-19 15:52:53 +00:00
Create default StructuredDataDef struct when none was specified so there is always a root struct
This commit is contained in:
parent
5327ce8ec9
commit
f061ff91f5
@ -95,7 +95,7 @@ void AssetLoaderStructuredDataDefSet::ConvertStruct(StructuredDataStruct* output
|
||||
outputProperty.name = memory->Dup(inputProperty.m_name.c_str());
|
||||
outputProperty.type = ConvertType(inputProperty.m_type);
|
||||
|
||||
if(outputProperty.type.type != DATA_BOOL)
|
||||
if (outputProperty.type.type != DATA_BOOL)
|
||||
{
|
||||
assert(inputProperty.m_offset_in_bits % 8 == 0);
|
||||
outputProperty.offset = inputProperty.m_offset_in_bits / 8;
|
||||
|
@ -101,18 +101,34 @@ namespace sdd::def_scope_sequences
|
||||
});
|
||||
}
|
||||
|
||||
private:
|
||||
static void CreateDefaultStructWhenNoStructsSpecified(const StructuredDataDefParserState* state)
|
||||
{
|
||||
if (state->m_current_def->m_structs.empty())
|
||||
{
|
||||
state->m_current_def->m_structs.emplace_back(std::make_unique<CommonStructuredDataDefStruct>());
|
||||
state->m_current_def->m_root_type = CommonStructuredDataDefType(CommonStructuredDataDefTypeCategory::STRUCT, 0u);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetDefSizeFromRootStruct(const StructuredDataDefParserState* state)
|
||||
{
|
||||
if (state->m_current_def->m_root_type.m_category == CommonStructuredDataDefTypeCategory::STRUCT
|
||||
&& state->m_current_def->m_root_type.m_info.type_index < state->m_current_def->m_structs.size())
|
||||
{
|
||||
const auto* _struct = state->m_current_def->m_structs[state->m_current_def->m_root_type.m_info.type_index].get();
|
||||
state->m_current_def->m_size_in_byte = _struct->m_size_in_byte;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
void ProcessMatch(StructuredDataDefParserState* state, SequenceResult<SimpleParserValue>& result) const override
|
||||
{
|
||||
assert(state->m_current_enum == nullptr);
|
||||
assert(state->m_current_struct == nullptr);
|
||||
|
||||
if(state->m_current_def->m_root_type.m_category == CommonStructuredDataDefTypeCategory::STRUCT
|
||||
&& state->m_current_def->m_root_type.m_info.type_index < state->m_current_def->m_structs.size())
|
||||
{
|
||||
const auto* _struct = state->m_current_def->m_structs[state->m_current_def->m_root_type.m_info.type_index].get();
|
||||
state->m_current_def->m_size_in_byte = _struct->m_size_in_byte;
|
||||
}
|
||||
CreateDefaultStructWhenNoStructsSpecified(state);
|
||||
SetDefSizeFromRootStruct(state);
|
||||
|
||||
state->m_current_def = nullptr;
|
||||
state->m_def_types_by_name.clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user