From 1b08ab2b1cc098eb1edefcb3c15d0f6ecb51ceaf Mon Sep 17 00:00:00 2001 From: duckdoom4 <60387522+duckdoom4@users.noreply.github.com> Date: Thu, 6 Jul 2023 00:48:07 +0200 Subject: [PATCH] Port over some bug fixes from the other branch --- pkNX.Containers/FolderContainer.cs | 4 ++-- pkNX.Containers/Misc/GFPack.cs | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkNX.Containers/FolderContainer.cs b/pkNX.Containers/FolderContainer.cs index b53462c5..b47d0996 100644 --- a/pkNX.Containers/FolderContainer.cs +++ b/pkNX.Containers/FolderContainer.cs @@ -41,7 +41,7 @@ public void AddFile(string file, byte[]? data = null) { Paths.Add(file); Data.Add(data); - TrackModify.Add(false); + TrackModify.Add(data != null); } public void AddFiles(IEnumerable files) @@ -90,7 +90,7 @@ public void ResetIndex(int index) public bool Modified { get => TrackModify.Contains(true); - set => CancelEdits(); + set { if (!value) CancelEdits(); } } public int Count => Paths.Count; diff --git a/pkNX.Containers/Misc/GFPack.cs b/pkNX.Containers/Misc/GFPack.cs index 62ba9e87..83d0c65c 100644 --- a/pkNX.Containers/Misc/GFPack.cs +++ b/pkNX.Containers/Misc/GFPack.cs @@ -128,7 +128,11 @@ public byte[] GetDataFileName(string name) return DecompressedFiles[index]; } - public byte[] GetDataFull(ulong hash) => DecompressedFiles[GetIndexFull(hash)]; + public byte[] GetDataFull(ulong hash) + { + var fileId = GetIndexFull(hash); + return fileId < 0 ? Array.Empty() : DecompressedFiles[fileId]; + } public byte[] GetDataFullPath(string path) => GetDataFull(FnvHash.HashFnv1a_64(path));