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:
parent
0fc013ff17
commit
c0d65208bc
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user