Skip to content

Instantly share code, notes, and snippets.

@cheahjs
Last active February 11, 2024 01:13
Show Gist options
  • Save cheahjs/300239464dd84fe6902893b6b9250fd0 to your computer and use it in GitHub Desktop.
Save cheahjs/300239464dd84fe6902893b6b9250fd0 to your computer and use it in GitHub Desktop.
Converting PalWorld saves to JSON and back
@iebb
Copy link

iebb commented Jan 24, 2024

Created a website for this - https://palworld.tf/ , where you can do this conversion in-browser by dragging files with wasm-compiled uesave-rs without downloading these.

@KrisDevel0pment
Copy link

Created a website for this - https://palworld.tf/ , where you can do this conversion in-browser by dragging files with wasm-compiled uesave-rs without downloading these.

Doesn't work.

@iebb
Copy link

iebb commented Jan 25, 2024

Created a website for this - https://palworld.tf/ , where you can do this conversion in-browser by dragging files with wasm-compiled uesave-rs without downloading these.

Doesn't work.

wait a moment, just messed up with the latest commit... should work now

@bhaktas
Copy link

bhaktas commented Jan 26, 2024

is there a way to convert steam save to xgp save?

@DKingAlpha
Copy link

Script to find PlayerUId (Players/<GUID>.sav)

#!/usr/bin/python3

from pathlib import Path
from struct import unpack_from
import json

j = json.loads(Path('temp/Level.2.json').read_text())
CharacterSaveParameterMap = j['root']['properties']['worldSaveData']['Struct']['value']['Struct']['CharacterSaveParameterMap']['Map']['value']

def find_user(name: str) -> str:
    for item in CharacterSaveParameterMap:
        key = item['key']
        value = item['value']
        PlayerUId = key['Struct']['Struct']['PlayerUId']['Struct']['value']['Guid']
        PlayerUIdInt = int(PlayerUId.replace('-', ''), 16)
        if PlayerUIdInt == 0:
            continue
        RawDataBytes = bytes(value['Struct']['Struct']['RawData']['Array']['Base']['Byte']['Byte'])
        pattern = b'\x4E\x69\x63\x6B\x4E\x61\x6D\x65\x00\x0C\x00\x00\x00\x53\x74\x72\x50\x72\x6F\x70\x65\x72\x74\x79\x00'
        offset = RawDataBytes.find(pattern)
        off_size = 0x22
        if offset == -1:
            print('not found')
            continue
        NickNameSize = unpack_from('<i', RawDataBytes, offset+off_size)[0]
        if NickNameSize >= 0:
            NickName = RawDataBytes[offset+off_size+4:offset+off_size+4+NickNameSize].decode('utf-8')
        else:
            max_bytes = (-NickNameSize) * 4
            NickName = RawDataBytes[offset+off_size+4:offset+off_size+4+max_bytes].decode('utf-16-le')[:-NickNameSize]
        NickName = NickName.rstrip('\x00')
        print(PlayerUId, NickName, end='')
        if NickName == name:
            print('\t\t\tFOUND')
        else:
            print('')

find_user('DKingAlpha')

@DKingAlpha
Copy link

@ShadyGame
Copy link

Got an error when trying to convert from sav to json.

Converting .sav files in ...\4790F9AF9E344A9987A3DE28B3762C72 to JSON (using uesave.exe)
Traceback (most recent call last):
File "...\convert-to-json.py", line 94, in
main()
File "...\convert-to-json.py", line 57, in main
uncompressed_data = zlib.decompress(data[12:])
^^^^^^^^^^^^^^^^^^^^^^^^^^
zlib.error: Error -3 while decompressing data: invalid stored block lengths

Env info

  • Python: 3.11.4
  • Game Ver: Steam Dedicated Server v0.1.2.0
  • Server: Ubuntu 22.04
  • Script running machine: Windows 11

i have the same error any solution ?

@Croock92
Copy link

Croock92 commented Feb 7, 2024

Got a keyerror: 'groupsavedatamap' someone can help me ? :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment