Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource: flatten unit right after parsing #283

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/resource/unit_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -655,13 +655,18 @@ namespace unit_compiler
return 0;
}

s32 flatten(UnitCompiler &c, CompileOptions &opts);

s32 parse_unit_from_json(UnitCompiler &c, const char *unit_json, CompileOptions &opts)
{
s32 err = collect_prefabs(c, StringId64(), unit_json, true, opts);
ENSURE_OR_RETURN(err == 0, opts);

u32 original_unit = c._prefab_offsets[array::size(c._prefab_offsets) - 1];
return parse_unit_internal(c, &c._prefab_data[original_unit], NULL, NULL, opts);
err = parse_unit_internal(c, &c._prefab_data[original_unit], NULL, NULL, opts);
ENSURE_OR_RETURN(err == 0, opts);

return flatten(c, opts);
}

s32 parse_unit(UnitCompiler &c, const char *path, CompileOptions &opts)
Expand Down Expand Up @@ -689,7 +694,7 @@ namespace unit_compiler
ENSURE_OR_RETURN(err == 0, opts);
}

return 0;
return flatten(c, opts);
}

s32 flatten_unit(UnitCompiler &c, Unit *unit, u32 parent_unit_index, CompileOptions &opts)
Expand Down Expand Up @@ -803,9 +808,6 @@ namespace unit_compiler
FileBuffer fb(output);
BinaryWriter bw(fb);

s32 err = flatten(c, opts);
ENSURE_OR_RETURN(err == 0, opts);

// Count component types.
u32 num_component_types = 0;
auto cur = hash_map::begin(c._component_data);
Expand Down
Loading