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

- 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:
DrakiaXYZ 2025-01-07 16:38:51 -08:00
parent 316dc33607
commit 84d2821d07

View File

@ -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;
}
}