From 84d2821d0704e3fc0e33f1515eb16645e322dcec Mon Sep 17 00:00:00 2001 From: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Date: Tue, 7 Jan 2025 16:38:51 -0800 Subject: [PATCH] Save virtual registry on application quit - Explicitly call PlayerPrefs.Save on application quit, since Unity doesn't seem to do it (any more?) - Remove previously added Save calls from Set methods --- .../SPT.Custom/Patches/SaveRegistryToSptFolderPatches.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/project/SPT.Custom/Patches/SaveRegistryToSptFolderPatches.cs b/project/SPT.Custom/Patches/SaveRegistryToSptFolderPatches.cs index 166a38f..e046d64 100644 --- a/project/SPT.Custom/Patches/SaveRegistryToSptFolderPatches.cs +++ b/project/SPT.Custom/Patches/SaveRegistryToSptFolderPatches.cs @@ -61,6 +61,9 @@ namespace SPT.Custom.Patches { ConsoleScreen.LogError($"Unable to parse registry file, defaulting to empty: {e.Message}"); } + + // Make sure we save the registry on exit, for some reason this isn't triggering by Unity itself + Application.quitting += PlayerPrefs.Save; } public class PatchPlayerPrefsSetInt : ModulePatch @@ -75,7 +78,6 @@ namespace SPT.Custom.Patches private static bool PatchPrefix(string key, int value) { _sptRegistry[key] = value; - PlayerPrefs.Save(); return false; } } @@ -92,7 +94,6 @@ namespace SPT.Custom.Patches private static bool PatchPrefix(string key, float value) { _sptRegistry[key] = value; - PlayerPrefs.Save(); return false; } } @@ -109,7 +110,6 @@ namespace SPT.Custom.Patches private static bool PatchPrefix(string key, string value) { _sptRegistry[key] = value; - PlayerPrefs.Save(); return false; } }