0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00

Save virtual registry on application quit (#22)

- 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
This commit is contained in:
Chomp 2025-01-08 09:09:52 +00:00 committed by GitHub
commit 77aa9496a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -61,6 +61,9 @@ namespace SPT.Custom.Patches
{ {
ConsoleScreen.LogError($"Unable to parse registry file, defaulting to empty: {e.Message}"); 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 public class PatchPlayerPrefsSetInt : ModulePatch
@ -75,7 +78,6 @@ namespace SPT.Custom.Patches
private static bool PatchPrefix(string key, int value) private static bool PatchPrefix(string key, int value)
{ {
_sptRegistry[key] = value; _sptRegistry[key] = value;
PlayerPrefs.Save();
return false; return false;
} }
} }
@ -92,7 +94,6 @@ namespace SPT.Custom.Patches
private static bool PatchPrefix(string key, float value) private static bool PatchPrefix(string key, float value)
{ {
_sptRegistry[key] = value; _sptRegistry[key] = value;
PlayerPrefs.Save();
return false; return false;
} }
} }
@ -109,7 +110,6 @@ namespace SPT.Custom.Patches
private static bool PatchPrefix(string key, string value) private static bool PatchPrefix(string key, string value)
{ {
_sptRegistry[key] = value; _sptRegistry[key] = value;
PlayerPrefs.Save();
return false; return false;
} }
} }