Fixed writing of EOFC in f2_struct when POF or ENRS is present

This commit is contained in:
korenkonder
2025-06-03 13:59:16 +03:00
parent a004391e29
commit 7874e59644
+5 -4
View File
@@ -146,14 +146,15 @@ static void f2_struct_get_length(f2_struct* s, bool shift_x) {
l += F2_HEADER_DEFAULT_LENGTH + align_val(s->pof.length(), 0x10);
}
if (has_sub_structs) {
if (has_sub_structs)
for (f2_struct& i : s->sub_structs) {
f2_struct_get_length(&i, shift_x);
l += i.header.get_data_size();
l += i.header.get_length();
}
if (has_enrs || has_pof || has_sub_structs)
l += F2_HEADER_DEFAULT_LENGTH;
}
s->header.set_data_size(l);
}
@@ -207,12 +208,12 @@ static void f2_struct_write_inner(stream& s, f2_struct* st, uint32_t depth, bool
f2_struct_write_enrs(s, &st->enrs, use_depth ? depth + 1 : 0);
if (has_pof)
f2_struct_write_pof(s, &st->pof, use_depth ? depth + 1 : 0, shift_x);
if (has_sub_structs) {
if (has_sub_structs)
for (f2_struct& i : st->sub_structs)
f2_struct_write_inner(s, &i, depth + 1, use_depth, shift_x);
if (has_enrs || has_pof || has_sub_structs)
f2_header('EOFC', 0, use_depth ? depth + 1 : 0).write(s);
}
if (!depth) {
f2_header('EOFC', 0).write(s);