From 42f302eff0e5e21f9a867fc495763eef09dae458 Mon Sep 17 00:00:00 2001 From: Viv Date: Fri, 2 Jun 2023 16:33:41 -0400 Subject: [PATCH] `tja2fumen.py`: Add workaround for `deo_n.bin` song I think this file has inaccurate metadata, so I've added a workaround so that it will still parse. --- tja2fumen/tja2fumen.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tja2fumen/tja2fumen.py b/tja2fumen/tja2fumen.py index 0d3558a..d349986 100644 --- a/tja2fumen/tja2fumen.py +++ b/tja2fumen/tja2fumen.py @@ -269,7 +269,12 @@ def readStruct(file, order, format_string, seek=None): """ if seek: file.seek(seek) - byte_string = file.read(struct.calcsize(order + format_string)) + expected_size = struct.calcsize(order + format_string) + byte_string = file.read(expected_size) + # One "official" fumen (AC11\deo\deo_n.bin) runs out of data early + # This workaround fixes the issue by appending 0's to get the size to match + if len(byte_string) != expected_size: + byte_string += (b'\x00' * (expected_size - len(byte_string))) interpreted_string = struct.unpack(order + format_string, byte_string) return interpreted_string