Tyulis / 3DSkit

A multi-purpose and pluggable program to extract and repack files found in 3DS (and some other Nintendo consoles) games
GNU General Public License v3.0
68 stars 11 forks source link

BFFNT OverflowError: signed integer is greater than maximum #15

Closed Enovale closed 6 years ago

Enovale commented 6 years ago

When extracting a large BFFNT (8 MB), the program returns

OverflowError: signed integer is greater than maximum

It extracts many other, smaller BFFNT's successfully but not the larger one.

EDIT: This is a Switch BFFNT

Tyulis commented 6 years ago

Wow, I never seen any OverflowError in Python for years ! Anyway. I don't have enough info. Can you send the full console output and eventually the file, to see from where it comes ?

Enovale commented 6 years ago

File: https://anonfiles.com/Q509Kbf8b1/PictureFont80.bffnt

Console Output:

user$ python3 3DSkit.py -x PictureFont80.bffnt

--------PictureFont80.bffnt--------
No compression
BFFNT file found
Extracting...
Traceback (most recent call last):
  File "3DSkit.py", line 248, in <module>
    result = main(args, opts)
  File "3DSkit.py", line 168, in main
    extract_files(filename, args.big, args.format, args.verbose, opts)
  File "3DSkit.py", line 111, in extract_files
    unpack.extract(filename, file, format, endian, verbose, opts)
  File "/Users/user/Downloads/3DSkit-master/unpack/__init__.py", line 16, in extract
    unpacker = cls(*args)
  File "/Users/user/Downloads/3DSkit-master/util/utils.py", line 18, in __new__
    return self.main(*args, **kwargs)
  File "/Users/user/Downloads/3DSkit-master/unpack/BFFNT.py", line 83, in main
    self.readTGLP(data, self.tglpoffset - 8)
  File "/Users/user/Downloads/3DSkit-master/unpack/BFFNT.py", line 134, in readTGLP
    self.extract_underlying_BNTX(data)
  File "/Users/user/Downloads/3DSkit-master/unpack/BFFNT.py", line 186, in extract_underlying_BNTX
    rgba = self.extract_sheet(data, self.sheetwidth, self.sheetheight * self.sheetcount, sheetsize, BNTI_FORMAT_NAMES[format], swizzlesize)
  File "/Users/user/Downloads/3DSkit-master/unpack/BFFNT.py", line 150, in extract_sheet
    libkit.extractTiledTexture(indata, out, width, height, format, swizzlesize, self.byteorder == '<')
OverflowError: signed integer is greater than maximum

It occurred on both Mac and Windows

Tyulis commented 6 years ago

Ok, that's because your file is in an unknown format and the error code was misinterpreted. I fix this and try to add this format

Enovale commented 6 years ago

That seems weird because other buffets from the same game also worked.

Tyulis commented 6 years ago

They have not the same format, this is not a size issue. Try in verbose mode (-v) to see the format of the others, it is probably BC4, which is already supported.

Enovale commented 6 years ago

you're right, the one that doesn't work is RGBA8_SRGB and the others are BC4

Tyulis commented 6 years ago

Done! The error was stupid, the format was almost already supported, I just had to add the Switch swizzling to make it look like something. Now you can also use -O reverse=true to flip it automatically, because it is actually reversed.

Enovale commented 6 years ago

alright, thank you very much