GFPAK : Fix deleting file entries from improper folder indices

This commit is contained in:
KillzXGaming 2020-04-02 14:12:59 -04:00
parent e636da8d19
commit 32093a1822

View file

@ -962,22 +962,16 @@ namespace FirstPlugin
public bool DeleteFile(ArchiveFileInfo archiveFileInfo)
{
int index = 0;
foreach (FileEntry file in files)
int removeindex = files.IndexOf((FileEntry)archiveFileInfo);
foreach (var folder in folders)
{
//Remove folder references first
//Regenerate the indices after
foreach (var folder in folders)
{
for (int f = 0; f < folder.FileCount; f++)
if (folder.hashes[f].Index == index)
folder.hashes.RemoveAt(f);
}
index++;
for (int f = 0; f < folder.FileCount; f++)
if (folder.hashes[f].Index == removeindex)
folder.hashes.RemoveAt(f);
}
RegenerateFileIndices();
files.Remove((FileEntry)archiveFileInfo);
return true;