Port over some bug fixes from the other branch

This commit is contained in:
duckdoom4
2023-07-06 00:48:07 +02:00
parent e4151673c3
commit 1b08ab2b1c
2 changed files with 7 additions and 3 deletions

View File

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

View File

@@ -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<byte>() : DecompressedFiles[fileId];
}
public byte[] GetDataFullPath(string path) => GetDataFull(FnvHash.HashFnv1a_64(path));