cheahjs / palworld-save-tools

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

There are missing a "tab" in the file whitch named "palsav.py" at line 27. #96

Closed yanyvpingsheng closed 8 months ago

yanyvpingsheng commented 8 months ago

When I use this tool to decompress "sav" files whitch in the folder named "Players", it run well. But there was a error happening when I use it to decompress the file whitch named "Level.sav", the Exception said :

Traceback (most recent call last):
  File "E:\Downloads\palworld-save-tools-windows-v0.15.0\convert.py", line 115, in <module>
    main()
  File "E:\Downloads\palworld-save-tools-windows-v0.15.0\convert.py", line 53, in main
    convert_sav_to_json(args.filename, output_path, args.minify_json)
  File "E:\Downloads\palworld-save-tools-windows-v0.15.0\convert.py", line 72, in convert_sav_to_json
    raw_gvas, _ = decompress_sav_to_gvas(data)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\Downloads\palworld-save-tools-windows-v0.15.0\lib\palsav.py", line 27, in decompress_sav_to_gvas
    uncompressed_data = zlib.decompress(data[12:])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^
zlib.error: Error -3 while decompressing data: invalid stored block lengths

So i opened the py file and looked the code, i found something wrong here.

# begining at line 22
    if save_type == 0x31:
        # Check if the compressed length is correct
        if compressed_len != len(data) - 12:
            raise Exception(f"incorrect compressed length: {compressed_len}")
    # Decompress file
    uncompressed_data = zlib.decompress(data[12:])# something wrong! missing a tab here 
    if save_type == 0x32:
        # Check if the compressed length is correct
        if compressed_len != len(uncompressed_data):
            raise Exception(f"incorrect compressed length: {compressed_len}")
        # Decompress file
        uncompressed_data = zlib.decompress(uncompressed_data)

The save type is "0x32" in the file whitch named "Level.sav", but it in wrong branch when code running, because of the missing tab! Please fix the bug in next version, thanks.

wang-jt commented 8 months ago

Same Problem. Is the bug fixed?