Example #1
0
 private void GenerateAnmCfgStrings(GFBANMCFG cfg)
 {
     foreach (GFBANMCFG.Animation a in cfg.Config.Animations)
     {
         GFPAKHashCache.PutHash(a.FileName);
     }
 }
Example #2
0
        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();
        }