mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2024-11-26 22:10:17 +00:00
read item file from ArchiveManager, not using File API ; don't throw exception if item file was not found, but log error
This commit is contained in:
parent
20461c854b
commit
fdc42b1946
2 changed files with 15 additions and 3 deletions
|
@ -60,7 +60,7 @@ namespace SanAndreasUnity.Importing.Items
|
|||
|
||||
public static void ReadIde(string path)
|
||||
{
|
||||
var file = new ItemFile<Definition>(ArchiveManager.GetCaseSensitiveFilePath(Path.GetFileName(path)));
|
||||
var file = new ItemFile<Definition>(path);
|
||||
foreach (var obj in file.GetItems<Definition>().OfType<IObjectDefinition>())
|
||||
{
|
||||
_definitions.Add(obj.Id, obj);
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Linq;
|
|||
using System.Linq.Expressions;
|
||||
#endif
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SanAndreasUnity.Importing.Items
|
||||
{
|
||||
|
@ -152,9 +153,20 @@ namespace SanAndreasUnity.Importing.Items
|
|||
|
||||
public ItemFile(string path)
|
||||
{
|
||||
using (var reader = File.OpenText(path))
|
||||
string fileName = Path.GetFileName(path);
|
||||
|
||||
if (!Archive.ArchiveManager.FileExists(fileName))
|
||||
{
|
||||
Load(reader);
|
||||
Debug.LogError($"Item file not found: {path}");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var stream = Archive.ArchiveManager.ReadFile(fileName))
|
||||
{
|
||||
using (var reader = new StreamReader(stream))
|
||||
{
|
||||
Load(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue