private void GenerateAnmCfgStrings(GFBANMCFG cfg) { foreach (GFBANMCFG.Animation a in cfg.Config.Animations) { GFPAKHashCache.PutHash(a.FileName); } }
private void GeneratePokeStrings() { //Also check file name just in case if (FileName.Contains("pm")) { string baseName = FileName.Substring(0, 12); GFPAKHashCache.GeneratePokeStringsFromFile(baseName); } }
private string GetString(ulong fullHash, HashIndex fileHashIndex, byte[] Data) { var folderHash = fileHashIndex.Parent.hash; var fileHash = fileHashIndex.hash; bool hasFolderHash = false; string folder = ""; string folderHashName = GFPAKHashCache.GetHashName(folderHash); if (folderHashName != null) { hasFolderHash = true; folder = $"{folderHashName}/"; } if (!hasFolderHash) { folder = $"{folderHash.ToString("X")}/"; } string ext = FindMatch(Data); if (ext == ".bntx" || ext == ".bfres" || ext == ".bnsh" || ext == ".bfsha") { string fileName = GetBinaryHeaderName(Data); //Check for matches for shaders if (ext == ".bnsh") { if (FNV64A1.Calculate($"{fileName}.bnsh_fsh") == fileHash) { fileName = $"{fileName}.bnsh_fsh"; } else if (FNV64A1.Calculate($"{fileName}.bnsh_vsh") == fileHash) { fileName = $"{fileName}.bnsh_vsh"; } } else { fileName = $"{fileName}{ext}"; } if (hasFolderHash) { return($"{folder}{fileName}"); } else { return($"{folder}{fileName}[FullHash={fullHash.ToString("X")}]{ext}"); } } else { string fileHashName = GFPAKHashCache.GetHashName(fileHash); if (fileHashName != null) { if (hasFolderHash) { return($"{folder}{fileHashName}"); } else { return($"{folder}{fileHashName}[FullHash={fullHash.ToString("X")}]{ext}"); } } else { return($"{folder}{fileHash.ToString("X")}[FullHash={fullHash.ToString("X")}]{ext}"); } } }
public void Read(FileReader reader) { string Signature = reader.ReadString(8, Encoding.ASCII); if (Signature != "GFLXPACK") { throw new Exception($"Invalid signature {Signature}! Expected GFLXPACK."); } GFPAKHashCache.EnsureHashCache(); version = reader.ReadInt32(); uint padding = reader.ReadUInt32(); uint FileCount = reader.ReadUInt32(); FolderCount = reader.ReadInt32(); ulong FileInfoOffset = reader.ReadUInt64(); ulong hashArrayPathsOffset = reader.ReadUInt64(); ulong FolderArrayOffset = reader.ReadUInt64(); reader.Seek((long)FolderArrayOffset, SeekOrigin.Begin); List <UInt64> hashes = new List <UInt64>(); List <HashIndex> FolderFiles = new List <HashIndex>(); for (int i = 0; i < FolderCount; i++) { Folder folder = new Folder(); folder.Read(reader); folders.Add(folder); foreach (var hash in folder.hashes) { FolderFiles.Add(hash); } } reader.Seek((long)hashArrayPathsOffset, SeekOrigin.Begin); for (int i = 0; i < FileCount; i++) { ulong hash = reader.ReadUInt64(); hashes.Add(hash); } GeneratePokeStrings(); 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") && version != 0x1000) { 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.FileName = GetString(hashes[i], fileEntry.FolderHash, fileEntry.FileData); fileEntry.FilePathHash = hashes[i]; } GFPAKHashCache.WriteCache(); }