mtkennerly / ludusavi-playnite

Playnite plugin for save backups via Ludusavi
MIT License
141 stars 9 forks source link

Registry backup/restore issue with SCP: The Endurance #66

Closed Agitatio closed 6 months ago

Agitatio commented 6 months ago

Added it as a custom game in Ludusavi with registry path HKEY_CURRENT_USER\Software\Eleven\The Endurance, then added backup/restore tag to it in Playnite. I don't know which process breaks it though, backup or restore. A lot of values ended up as invalid DWORD, which resulted in data loss. Game is free, so if you're going to test it yourself can quickly check by changing options. They get wiped after a restore.

mtkennerly commented 6 months ago

Hi! I just tested this, and the "invalid DWORD" errors appear in Regedit immediately after starting the game for the first time, even without making any backups/restores in Ludusavi.

I found some information about the same issue for another game made with Unity: https://www.reddit.com/r/RotMG/comments/phu9fl/rotmg_transparency_is_broken_invalid_dword_32bit/

The "Invalid DWORD" is caused by the fact that ROTMG is storing a 64-bit float as a 32-bit binary value. Windows Registry is capable of handling this, and will happily return that 64-bit data when called, but because it's not matching the specified type regedit freaks out when viewing it.

Reluctant though I am to defend Deca's coding, I'm reasonably certain this isn't their fault. This is a known issue with Unity's PlayerPrefs API when storing floating-point values (Google "Unity PlayerPrefs DWORD" for examples).

Right now, Ludusavi sees the invalid entries and defaults them to 0 in a valid format, so when they're restored, they no longer match the invalid format that the game expects. I think it would make more sense for Ludusavi to just ignore any invalid entries and show an error message instead. I'll just need to do some testing to make sure that Ludusavi can recognize whether they're valid or not, or maybe there's a way to save them as-is even if they're invalid.

Here's a comparison if you use Regedit to export one of these invalid entries:

Agitatio commented 6 months ago

I see. I'd take either solution, even though saving them as is would be preferable. Thanks for looking into it!

mtkennerly commented 6 months ago

Fortunately, the winreg crate (which Ludusavi uses) fixed an issue related to this recently: https://github.com/gentoo90/winreg-rs/issues/61

I've updated Ludusavi to back up and restore these invalid entries as-is: https://github.com/mtkennerly/ludusavi/commit/8d74fbc3acb6ec5ba42c03923128bad77653dc17 , which will be included in the next release (0.22.0). I don't have a specific release date in mind yet, but I'd like to try to release it soon if possible.