From 1340c1a55f39d44b48fbed323bce2647be8d7ec5 Mon Sep 17 00:00:00 2001 From: HelloOO7 Date: Thu, 28 Jan 2021 19:19:31 +0100 Subject: [PATCH] GFPAK procedural anime config hashes --- .../FileFormats/Archives/GFPAK.cs | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/File_Format_Library/FileFormats/Archives/GFPAK.cs b/File_Format_Library/FileFormats/Archives/GFPAK.cs index ccbfb683..2465118c 100644 --- a/File_Format_Library/FileFormats/Archives/GFPAK.cs +++ b/File_Format_Library/FileFormats/Archives/GFPAK.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -570,22 +570,37 @@ namespace FirstPlugin hashes.Add(hash); } + GenerateHashList(); + reader.Seek((long)FileInfoOffset, SeekOrigin.Begin); for (int i = 0; i < FileCount; i++) { FileEntry fileEntry = new FileEntry(this); + fileEntry.Read(reader); + string Extension = FindMatch(fileEntry.FileData); + if (Extension.EndsWith("gfbanmcfg")) + { + GFBANMCFG cfg = new GFBANMCFG(); + cfg.Load(new MemoryStream(fileEntry.FileData)); + GenerateAnmCfgStrings(cfg); + } + + files.Add(fileEntry); + } + + for (int i = 0; i < FileCount; i++) + { + FileEntry fileEntry = files[i]; + for (int f = 0; f < FolderFiles.Count; f++) if (FolderFiles[f].Index == i) fileEntry.FolderHash = FolderFiles[f]; var dir = fileEntry.FolderHash.Parent; - fileEntry.Read(reader); fileEntry.FileName = GetString(hashes[i], fileEntry.FolderHash, fileEntry.FileData); fileEntry.FilePathHash = hashes[i]; - - files.Add(fileEntry); } } @@ -595,7 +610,6 @@ namespace FirstPlugin get { if (hashList == null) { - hashList = new Dictionary(); GenerateHashList(); } return hashList; @@ -604,6 +618,8 @@ namespace FirstPlugin private void GenerateHashList() { + hashList = new Dictionary(); + foreach (string hashStr in Properties.Resources.Pkmn.Split('\n')) { string HashString = hashStr.TrimEnd(); @@ -629,6 +645,14 @@ namespace FirstPlugin } } + private void GenerateAnmCfgStrings(GFBANMCFG cfg) + { + foreach (GFBANMCFG.Animation a in cfg.Config.Animations) + { + hashList.Add(FNV64A1.Calculate(a.FileName), a.FileName); + } + } + private void GeneratePokeStrings(string hashStr) { //Also check file name just in case