123456abcdef / cr-sc-dump

Python script to extract pngs from Supercell’s *.sc, *_dl.sc, or *_tex.sc files.
86 stars 33 forks source link

Does this work with 1.5 ? Getting garbled images. #2

Closed srabouin closed 7 years ago

srabouin commented 8 years ago

Hello,

I tried running this on the new 1.5 version and most files end up being garbage images instead. Only a handful unpack correctly. It might be a change of image size, I see the right colors but they're all misplaced. Any help would be greatly appreciated :)

Thanks in advance!

123456abcdef commented 8 years ago

Decompressing works the same, but fileType 28 is new. I compaired an old tex.sc wih a new one. It seems, like you said already, that the pixels itself are stored the same way (colors are still correct), but they are ordered different. Not sure when and if I will fix this script for the new version :P.

milanmaldini commented 8 years ago

what about clash of clans tex file? Is that can decompressing?

123456abcdef commented 8 years ago

CoC uses LZHAM, I think, and I don't know how to adjust the header to be able to decompress the files. Last time I check (a few month ago) you could get the decompressed files from the cache folder inside your CoC installation path and could extract the images using this script. But I guess Supercell did the same changes to CoC's tex files like they did in CR.

fpvolquind commented 8 years ago

Hi! This is the garbled image structure (tested with an image with width of 186 (chr_balloon_tex)):

pixels 0 to 31 (32 pixels) = pixels 0 to 31 of line 0 of final image pixels 32 to 63 = pixels 0 to 31 of line 1 of final image ... pixels 992 to 1023 = pixels 0 to 31 of line 31 of final image pixels 1024 to 1055 = pixels 32 to 63 of line 0 of final image ... pixels 2048 to 2079 = pixels 64 to 95 of line 0 of final image ... ... pixels 5088 to 5119 = pixels 128 to 159 of line 31 of final image pixels 5120 to 5145 (26 pixels = (width - (floor(width/32) * 32))) = pixels 160 to 185 of line 0 of final image pixels 5146 to 5171 (26 pixels) = pixels 160 to 185 of line 1 of final image ... pixels 5926 to 5951 = pixels 160 to 185 of line 31 of final image pixels 5952 to 5983 (32 pixels) = pixels 0 to 31 of line 32 of final image ... etc.

I'm currently testing with other images to check how it behaves at the end (chr_balloon_tex is all transparent pixels at the end).

fpvolquind commented 8 years ago

Tested with level_goblin_arena_tex. If there are less than 32 lines remaining, use this number instead of 32 to iterate through the remaining 32-pixels blocks and rebuild the final lines.

srabouin commented 7 years ago

@fpvolquind did you end up writing the code for this? you should submit a pull request :)

fpvolquind commented 7 years ago

Well, I wrote the code, but in another language. I'm not so great with python, but I'll give a shot.

srabouin commented 7 years ago

Can you paste the logic from whatever other language, I can also give it a shot

fpvolquind commented 7 years ago

Ugly as hell, but works. Just ran through all _tex.sc files, no garbled images.

srabouin commented 7 years ago

Tested in a few files and worked great, thank you @fpvolquind great work!

fpvolquind commented 7 years ago

You're welcome. Glad to help the community =)

srabouin commented 7 years ago

Hate to put that here, but any advice on getting the contents of the .sc file? like ui.sc contains all the clan badges -- it would be interesting to decode it?

fpvolquind commented 7 years ago

Yes, decoding the .sc files would be great, I'd love to have the animated sprites. The files are LZMA-compressed, similar to the _tex.sc files. There is a script around for QuickBMS that can decompress most of them. I couldn't get much sense out of the decompressed files yet, but they are some sort of texture atlas. I'll try looking at ui_spells to try and get some sense of the data.

srabouin commented 7 years ago

Looking at the clan badges csv, it looks like all the badges are in the ui.sc file -- using the bms script i can see all the file names in there too now, so at least getting somewhere... thanks for that!

http://aluigi.altervista.org/bms/clash_royale.bms

fpvolquind commented 7 years ago

Posted what I found here: http://zenhax.com/viewtopic.php?f=9&t=2369&p=18181

srabouin commented 7 years ago

@umop-aplsdn did you have any progress? I just thought of something, maybe they're using the unity3d sprite packer since it's the engine used for the game. Something else to play with maybe :)

https://docs.unity3d.com/Manual/SpritePacker.html

fpvolquind commented 7 years ago

Check out my repository, just updated my script. AFAIK, Supercell uses it's own game engine. I couldn't find any sample Unity texture atlas to compare with the sc files.