cheahjs / palworld-save-tools

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

feat: Add try to fix save function #75

Open YK-Samgo opened 6 months ago

YK-Samgo commented 6 months ago

My save was broken and caused failure as following. And I didn't find any tool to fix it.

LowLevelFatalError [File:G:/works/repos/Pal_SVN/Pal-UE-App/Source/Pal/PalWorldSecuritySystem.cpp] [Line: 43]
Not Found Police Group. InitializeWithSaveDataForServer
Signal 11 caught.
Malloc Size=262146 LargeMemoryPoolOffset=262162
CommonUnixCrashHandler: Signal=11
Malloc Size=131160 LargeMemoryPoolOffset=393352
Malloc Size=131160 LargeMemoryPoolOffset=524536
sh: 1: xdg-user-dir: not found
LogPakFile: Display: Found Pak file ../../../Engine/Programs/CrashReportClient/Content/Paks/CrashReportClient.pak attempting to mount.
LogPakFile: Display: Mounting pak file ../../../Engine/Programs/CrashReportClient/Content/Paks/CrashReportClient.pak.
LogPakFile: Display: Mounted Pak file '../../../Engine/Programs/CrashReportClient/Content/Paks/CrashReportClient.pak', mount point: '../../../Engine/'
LogICUInternationalization: ICU TimeZone Detection - Raw Offset: +0:00, Platform Override: ''
LogInit: Build: ++UE5+Release-5.1-CL-0
LogInit: Engine Version: 5.1.1-0+++UE5+Release-5.1
LogInit: Compatible Engine Version: 5.1.0-0+++UE5+Release-5.1
LogInit: Net CL: 0

Thanks to @cheahjs's job, I managed to fix my save. There were 4 single bit issues.

Error decoding ascii string of length 16, data loss may occur! b'Wo\xf2kSuitability' -> b'WorkSuitability'
Too large size 0x8005
Too large size 0x80000d
Error decoding ascii string of length 5, data loss may occur! b'\xceone' -> b'None'

Now I want to save others' savs.

YK-Samgo commented 6 months ago

Saves may mistake some single bits by adding 0x80 to one byte. For example, r (0x72 in ASCII) to 0xf2 and 0x5 to 0x8005.

Just minus 0x80 when meet error bytes.

This is reliable in words, but may not be so reliable in size. This is only an effort to bring your Pals back.

>>> b'r'.hex()
'72'
>>> b'N'.hex()
'4e'