From 7874e59644a9c94cee6f71c70e2eacaba20ab4e9 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Tue, 3 Jun 2025 13:59:16 +0300 Subject: [PATCH] Fixed writing of EOFC in `f2_struct` when `POF` or `ENRS` is present --- src/KKdLib/f2/struct.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/KKdLib/f2/struct.cpp b/src/KKdLib/f2/struct.cpp index 88d6016a..ad7583b8 100644 --- a/src/KKdLib/f2/struct.cpp +++ b/src/KKdLib/f2/struct.cpp @@ -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);