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

Added try/catch to SaveRegistryToSptFolderPatches to prevent code failing when malformed JSON is passed into it

Reduced indentation by inverting exists check
This commit is contained in:
Chomp 2024-12-13 10:17:30 +00:00
parent 0fc013ff17
commit c0d65208bc

View File

@ -4,6 +4,7 @@ using SPT.Reflection.Patching;
using System;
using System.IO;
using System.Reflection;
using EFT.UI;
using UnityEngine;
namespace SPT.Custom.Patches
@ -45,11 +46,21 @@ namespace SPT.Custom.Patches
Directory.CreateDirectory(_sptRegistryPath);
}
// Load the existing registry if found
if (File.Exists(_registryFilePath))
if (!File.Exists(_registryFilePath))
{
return;
}
try
{
// Load existing registry
_sptRegistry = JObject.Parse(File.ReadAllText(_registryFilePath));
}
catch (Exception e)
{
ConsoleScreen.LogError($"Unable to parse registry file, defaulting to empty: {e.Message}");
}
}
public class PatchPlayerPrefsSetInt : ModulePatch