cheahjs / palworld-save-tools

Tools for converting Palworld .sav files to JSON and back
MIT License
766 stars 64 forks source link

Save on Palworld from Windows Store #150

Closed guerrillian closed 4 months ago

guerrillian commented 4 months ago

Hi! My Palworld is from Windows Store and I don't have the save file in that folder image image

Found that they are here, but the files are different. image

Does anyone know how to convert?

Thanks.

DJStompZone commented 4 months ago

Same question here, but as far as I know the format is different for the Xbox version's saves. From what I've gathered so far, each of those folders in the wgs directory contains a save file (ex. "58304B09437B48F5B490958C1C980DAF") and some sort of very simple smaller file (ex. "container.7"), the latter of which seems like a manifest or something, the former being the save file itself. It's definitely compressed, but the magic bytes don't give any clues as to how exactly.

DJStompZone commented 4 months ago

Oooook 20 mins later (hacker voice) I'm in It's double-zlib zipped. Here's what I did:

import zlib

def zlib_decompress(in_file, out_file, offset=0):
    # Read the file as binary
    with open(in_file, 'rb') as f:
        # Skip the first <offset> bytes to where the zlib data begins
        f.seek(offset)
        compressed_data = f.read()
    # Attempt to decompress the data
    try:
        decompressed_data = zlib.decompress(compressed_data)
        with open(out_file, "wb") as fp:
            fp.write(decompressed_data)
    except zlib.error as e:
        print(f"Zlib decompression error: {e}")

def main():
    proj = "/home/dj/samples/pal"
    stage_0 = f"{proj}/58932BB30D8E4AA0A20DC8EDAAC2F859"
    stage_1, stage_2 = [f"{proj}/{ea}" for ea in ["decompressed.sav", "decompressed_again.sav"]]
    zlib_decompress(in_file=stage_0, out_file=stage_1, offset=12)
    zlib_decompress(in_file=stage_1, out_file=stage_2)

if __name__ == "__main__":
    main()

The first (outer) layer is an offset of 12, the inner (second) layer is an offset of 0. Once unzipped, we can see that we seem to have a proper UE 5.1 save file (I think?):

GVAS   
  �            ++UE5+Release-5.1

Does anyone want to collaborate on getting this project fully up and running for xbox saves? (plz I'm so lonely)

cheahjs commented 4 months ago

Out of scope for this tool, you want something like https://github.com/Z1ni/XGP-save-extractor to pull files out of Xbox Game Pass games, including Palworld.