FanTranslatorsInternational / Kuriimu2

Kuriimu is a general purpose game translation project manager and toolkit for authors of fan translations and game mods.
GNU General Public License v3.0
311 stars 56 forks source link

[Question] Is the "LZ4C" compression method in the *.fab file the standard lz4 compression? #145

Closed LITTOMA closed 3 years ago

LITTOMA commented 3 years ago

Hello! I'm not sure if this is the right place to ask a question, but I would appreciate it if you could answer.

Two months ago, I was working on the hacking jobs for the Chinese translation of Pokémon Art Academy. When I found some "LZ4C" nodes in the fab files, I presumed that they were compressed by the lz4 algorithm.

However, when I tried to decompress them with the lz4 tool, I experienced a failure. The standard lz4 decompressor does not seem to recognize these data.

Therefore, I gave up on compressing these files after modified. And the game engine reads these uncompressed files correctly. This compression algorithm was still a mystery to me until the time of the translation release.

So my question is: Is it the standard lz4 algorithm? If so, how can I compress/decompress it correctly?

Thank you in advance.

onepiecefreak3 commented 3 years ago

There already are plugins for this in Kuriimu2. It IS the standard LZ4 algorithm, but without the standard specified LZ4 header information. You basically assume some default settings to decompress it.

Have a look at the Fab plugin (https://github.com/FanTranslatorsInternational/Kuriimu2/blob/dev/plugins/HeadstrongGames/plugin_headstrong_games/Archives/Fab.cs) L39 and L40 specifically. It checks for the LZ4C magic, and then initializes the file as compressed with Lz4Headerless.

Using Kuriimu2 De-/Compression dialog, you can de-/compress a file with LZ4Headerless yourself. Or call Compressions.Lz4Headerless from the Kompression library in code to de-/compress via code.

If this answered your questions, please close the issue.

LITTOMA commented 3 years ago

I got it. Thanks.