Unpacking playerstats.pck

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

klingens
Posts: 422
Joined: Wed, 3. Dec 03, 09:38

Unpacking playerstats.pck

Post by klingens »

I want to look what data is in my playerstats.pck file and tried X3MM (2.x) and x2archiver to unpack it. Neither worked: first one gave an error, 2nd one a 0 byte file.

Is there a way to make this pck file human readable?
klingens
Posts: 422
Joined: Wed, 3. Dec 03, 09:38

Post by klingens »

Damn, wrong forum (I'm using X3TC).
To the mods: please move, thank you.
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

It's just a zip file - use 7zip or similar to unpack it.
klingens
Posts: 422
Joined: Wed, 3. Dec 03, 09:38

Post by klingens »

A file beginning with bytes

Code: Select all

1F 8B
is no zip-file. Zip-files begin with the two lettters "PK"
User avatar
Carlo the Curious
Posts: 16999
Joined: Mon, 5. Mar 07, 22:03
x4

Post by Carlo the Curious »

Whatever. 7zip still works.
jlehtone
Posts: 22499
Joined: Sat, 23. Apr 05, 21:42
x4

Post by jlehtone »

Deflated with zlib. Most compression programs can Inflate it.
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22432
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow »

klingens wrote:A file beginning with bytes

Code: Select all

1F 8B
is no zip-file. Zip-files begin with the two lettters "PK"
actually its a zip file, not a zip archive.

theres a difference.

zip archives are usually multiple files, zipped up into a single file.

this is just a file thats been compressed on its own, the format is actually the same as it uses zlib.

most good zip tools can uncompress it
klingens
Posts: 422
Joined: Wed, 3. Dec 03, 09:38

Post by klingens »

The format (header) is different as outlined above. The algorithm zlib uses (DEFLATE, a LZ77 variant) is the same as most zipfiles use.

Thanks for the info, now I could unpack the file and read the xml.
doubleshadow
Posts: 671
Joined: Fri, 12. Mar 04, 08:14
x3

Post by doubleshadow »

Can I also play "who is smarter" with you kids?

The container is GZIP
The compression is Deflate.

You can have GZIP with other compression, but it has never been implemented.
You can have pure Deflate stream without container - you save some 20 bytes and lost metadata such as ModifiedDate and CRC

@klingens: X3MM 0.0.8 can extract X2 and X3TC .pcks via shell context menu. You just need to associate it with .pck extension in Settings->File Association. Then right click on the file in Explorer. The "Open" button only works for catalogs.
User avatar
SpaceAcid
Posts: 63
Joined: Tue, 7. Feb 12, 06:20

This Works Best

Post by SpaceAcid »


this is for those of you who can't seem to get a .pck file extracted
using 7-zip & Winrar..


______________________________________________________

Quoted from: DrBullWinkle who helped me fix this frustrating issue
______________________________________________________
DrBullwinkle wrote:
SpaceAcid wrote:cannot for the life of me figure out how to extract the compressed xml from .pck files using 7-Zip

everywhere in the forums they all say it works
Yeah, that puzzled me at first, too. It turns out that some .pck's can be unzipped with 7-zip, while others cannot. Most "helpful" threads on the subject are incomplete.

The explanation that I received was that there are two different compression techniques and one of them (the older method) is encrypted. The plugin manager uses the encrypted technique. If I recall correctly, the X3 Editor also defaults to the encrypted technique.

The solution is to use X3 Editor:
  • 1) Open the Cat Manager from the Plugins Menu.
    2) Create a New Catalog. Give it any name you like. I call mine "Packer.cat" but any name will do.
    3) Drag and drop the .pck from Windows Explorer to the new .cat.
    4) Drag and drop the .pck back to Windows Explorer. X3 Editor should automatically decompress the file.
Also, the Script Editor (any of them) can open .pck files directly, so there is rarely a need to decompress a script file.
you need > X3 editor 2

hope this helps somebody else!
akari no ryu
Posts: 143
Joined: Sun, 11. Oct 09, 14:32
x4

Post by akari no ryu »

doubleshadow wrote:Can I also play "who is smarter" with you kids?

The container is GZIP
The compression is Deflate.

You can have GZIP with other compression, but it has never been implemented.
You can have pure Deflate stream without container - you save some 20 bytes and lost metadata such as ModifiedDate and CRC
And the crowd goes wild!
Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22432
Joined: Sun, 14. Nov 04, 23:26
x4

Re: This Works Best

Post by Cycrow »

SpaceAcid wrote:
this is for those of you who can't seem to get a .pck file extracted
using 7-zip & Winrar..


______________________________________________________

Quoted from: DrBullWinkle who helped me fix this frustrating issue
______________________________________________________
DrBullwinkle wrote:
SpaceAcid wrote:cannot for the life of me figure out how to extract the compressed xml from .pck files using 7-Zip

everywhere in the forums they all say it works
Yeah, that puzzled me at first, too. It turns out that some .pck's can be unzipped with 7-zip, while others cannot. Most "helpful" threads on the subject are incomplete.

The explanation that I received was that there are two different compression techniques and one of them (the older method) is encrypted. The plugin manager uses the encrypted technique. If I recall correctly, the X3 Editor also defaults to the encrypted technique.

The solution is to use X3 Editor:
  • 1) Open the Cat Manager from the Plugins Menu.
    2) Create a New Catalog. Give it any name you like. I call mine "Packer.cat" but any name will do.
    3) Drag and drop the .pck from Windows Explorer to the new .cat.
    4) Drag and drop the .pck back to Windows Explorer. X3 Editor should automatically decompress the file.
Also, the Script Editor (any of them) can open .pck files directly, so there is rarely a need to decompress a script file.
you need > X3 editor 2

hope this helps somebody else!
first point, this thread is almost 4 years old, was there really a need to resurrect it ?

second, to make things clear about the 2 types of files.
Both use the same compression, but one has an Xor encryption applied to it as well.

The Xor method was the default for earier games, so all files in X3R were ilke this. These can be unpacked like a zip file, but they first need the encryption removed

In TC this changed and it was removed so it was just a standard gzip file

both the plugin manager and X3 editor can use both formats
you can also use the official modding tools (from X2) to unpack these files. Or the plugin manager tools can do it as well.

So if 7-zip doen't work then most likly its because its the older format and needs to use different tools
akruppa
Posts: 31
Joined: Fri, 25. Oct 13, 13:57
x3ap

Post by akruppa »

From what I can gather from the X-Editor 2 source code, the "encrypted" file consists of one (random?) byte, followed by the gzipped file byte-wise xor-ed by that byte. Is this correct? If yes, I'll add the decryption to the Python script so the resulting file can be gunzip-ed.

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”