123456abcdef / cr-sc-dump

Python script to extract pngs from Supercell’s *.sc, *_dl.sc, *_tex.sc, *.csv, *.ktx, and *.sctx files.
87 stars 33 forks source link

LZMAError Input format not supported by decoder #23

Closed ToxifireX closed 1 year ago

ToxifireX commented 1 year ago

\path\to\assets\sc\ui_spells.sc --old ui_spells.sc LZMAError Input format not supported by decoder

\path\to\assets\sc\ui_spells.sc ui_spells.sc LZMAError Input format not supported by decoder

I am using python 3.11.5 (latest 09/02/23) I have retrieved the Clash Royale files by installing them from apkpure.com Clash Royale version 3.33145, then renaming the file to end in .zip, and extracting. I am using Windows 10 Pro OS Build 19045.3324 on Command Prompt (cmd).

123456abcdef commented 1 year ago

Try using ui_spells_tex.sc if available. If I remember correctly Most of CR's *.sc don't contain PNGs.

ToxifireX commented 1 year ago

Alright. Thank you.

123456abcdef commented 1 year ago

Did it work with using *_tex.sc files?

ToxifireX commented 1 year ago

Yea, it did. I decompressed all of them, but didn't find the card icons for a lot of cards. I noticed that some of the newer cards are in their own ui_spell_[card].sc file, and not ui_spells_tex.sc. For example, ui_spell_zappies.sc & evolution_mortar.sc. I noticed there are no tex.sc to match these. I am trying to get the evolution mortar.png. Thanks

123456abcdef commented 1 year ago

Most of the *.sc are not part of the APK itself but get downloaded when you start the app on your device. This way SC can easier update most of their assets. There are two ways to get the additional files, pull them directly from your device or use sc-assets-download. For the latter you might need to update some hashes/version numbers in the code itself to pull the newest files.

ToxifireX commented 1 year ago

Ok, I didn't know that and thanks I will try it.

ToxifireX commented 1 year ago

Hi, do you know where I can find the evolution card icon images? Like this one: image

Ok, I found it in spells_evolved.csv, but I run into the same issue that I opened this issue for. The file is ui_spells_mortar_evolution.sc, but it runs into the LZMA issue. Do you know any way that I can decode it? Thanks.

123456abcdef commented 1 year ago

python dumpsc.py --old ui_spell_mortar_evolution.sc

Exactly how it is explained in the README.md.

ToxifireX commented 1 year ago

Capture

123456abcdef commented 1 year ago

Ok figured it out for some reason zstandard.MAGIC_NUMBER returns a different value on Windows than on Linux. Could you please change line 55 from

elif int.from_bytes(data[0:4], byteorder="little") == zstandard.MAGIC_NUMBER:

to

elif int.from_bytes(data[0:4], byteorder="little") == 0xfd2fb528:

In the meantime I try to figure out why there is a OS specific difference.

ToxifireX commented 1 year ago

Alright, thanks for looking into it, and I will try it and let you know the result when I get the chance.

ToxifireX commented 1 year ago

Thanks you so much for helping me, and it has worked. One last question: are *.sc files and *_tex.sc files coded in the same way? Thanks again.

123456abcdef commented 1 year ago

Thank you for hanging on and testing in your environment. There are *.sc, *_dl.sc, and *_tex.sc depending on the game they are compressed with different algorithms. *_dl.sc and *_tex.sc only contain assets. *.sc sometime contain assets. Never really investigated the *.sc further.

ToxifireX commented 1 year ago

Do you know what type of compression each file uses in Clash Royale? I tried to figure it out using --verbose in your code, but it always says Decompressing using ZSTD. However, when I use Galaxy1036's code, it says LZMA Compression Detected every time. I am interested because I would like to recompress the files in their original compression.

123456abcdef commented 1 year ago

If the script prints Decompressing using ZSTD ... it should be correct otherwise it is LZMA or LZHAM. What compression is used is not depending on the game but on the file header itself. I'm not to sure about the logic when what compression is used.

ToxifireX commented 1 year ago

Alright, thank you for helping me along the way. I'll close this issue now.