Example #1
0
        public static TAHEntry Load(BinaryReader br, TAHFile file)
        {
            TAHEntry h = new TAHEntry();

            h.Read(br, file);
            return(h);
        }
Example #2
0
        public static TAHDirectories Load(BinaryReader br, TAHFile file)
        {
            TAHDirectories dir = new TAHDirectories();

            dir.Read(br, file);
            return(dir);
        }
Example #3
0
        public void Read(BinaryReader br, TAHFile file)
        {
            Entries  = new List <TAHEntry>(file.Header.NumEntries);
            EntryMap = new Dictionary <uint, TAHEntry>();

            for (int i = 0, n = file.Header.NumEntries; i < n; ++i)
            {
                TAHEntry e = TAHEntry.Load(br, file);

                if (i != 0)
                {
                    TailEntry.Length = (int)(e.DataOffset - TailEntry.DataOffset);
                }
                //Console.WriteLine(e.ToString());
                Entries.Add(e);
                if (EntryMap.ContainsKey(e.Hash))
                {
                    //Console.WriteLine("Error: delect hashkey collision. " + e.Hash.ToString("X8") + ": " + e.DataOffset.ToString());
                    Debug.WriteLine("Error: detect hashkey collision. " + e.Hash.ToString("X8") + ": " + e.DataOffset.ToString());
                }
                else
                {
                    EntryMap.Add(e.Hash, e);
                }
            }

            TailEntry.Length = (int)(br.BaseStream.Length - TailEntry.DataOffset);
        }
Example #4
0
        public static TAHEntrySet Load(BinaryReader br, TAHFile file)
        {
            TAHEntrySet es = new TAHEntrySet();

            es.Read(br, file);
            return(es);
        }
Example #5
0
 // ファイルをオープンする
 private static void OpenRead()
 {
     foreach (string filename in filenames)
     {
         Program.SetRescent(filename);
         FileStream fs = File.OpenRead(filename);
         tahfiles[filename] = new TAHFile(fs);
         tahfiles[filename].LoadEntries();
     }
 }
Example #6
0
        public void Read(BinaryReader br, TAHFile file)
        {
            // ディレクトリデータの読み込み
            Files = new List <string>(file.Header.NumEntries);
            int output_length = br.ReadInt32();
            int input_length  = (int)(file.EntrySet[0].DataOffset - br.BaseStream.Position); //- 16 - 8 * file.Header.NumEntries;

            byte[] input  = br.ReadBytes(input_length);
            byte[] output = new byte[output_length];

            if (output.Length == 0)
            {
                return;
            }

            // add konoa:tahdecryptorのバグ回避.
            if (input.Length == 0)
            {
                return;
            }

            TAHUtil.Decrypt(input, output);
            //TAHdecrypt.Decrypter.decrypt(ref input, (uint)input.Length, ref output, (uint)output.Length);

            MemoryStream ms  = new MemoryStream(output);
            BinaryReader br2 = new BinaryReader(ms);

            try
            {
                string dir = "";

                while (ms.Position < ms.Length)
                {
                    string name = TAHUtil.ReadString(br2);

                    if (name.Length == 0)
                    {
                    }
                    else
                    if (name.EndsWith("/"))
                    {
                        dir = name;
                        //DbgPrint("Directory:            " + dir);
                    }
                    else
                    {
                        name = dir + name;
                        uint     hash = TAHUtil.CalcHash(name);
                        TAHEntry ent;

                        //DbgPrint(hash.ToString("X").PadLeft(8, '0'));

                        if (file.EntrySet.TryGetValue(hash, out ent))
                        {
                            ent.FileName = name;
                            //DbgPrint(": Found:     " + file);
                        }
                        else
                        {
                            //DbgPrint(": Not Found: " + file);
                            System.Diagnostics.Debug.Assert(false);
                        }

                        //EntryMap[hash].FileName = FileName;
                    }

                    Files.Add(name);
                }
            }
            catch (EndOfStreamException)
            {
            }
        }
Example #7
0
 public void Read(BinaryReader br, TAHFile file)
 {
     Hash       = br.ReadUInt32();
     FileName   = FindExternalFileName(Hash);
     DataOffset = br.ReadUInt32();
 }
Example #8
0
        // カラーを処理する
        private static void CheckColorTable()
        {
            foreach (string filename in filenames)
            {
                Dictionary <string, List <string> > coltables = new Dictionary <string, List <string> >();
                TAHFile tahfile = tahfiles[filename];
                int     total   = tahfile.EntrySet.Entries.Count;

                foreach (TAHEntry entry in tahfile.EntrySet.Entries)
                {
                    string newfilename = GetFileName(entry);

                    string dir  = Path.GetDirectoryName(newfilename);
                    string file = Path.GetFileName(newfilename);

                    if (Path.GetExtension(file.ToLower()) == ".tbn")
                    {
                        if (file.Length != 16)
                        {
                            continue;
                        }
                        //         1234567890123456
                        // file = "NhsaFHEA_B00.tbn"
                        string name = file.ToLower().Substring(1, 8);
                        string col  = file.ToLower().Substring(9, 3);
                        // nameとcolのdictionaryを作る.
                        if (coltables.ContainsKey(name) == true)
                        {
                            coltables[name].Add(col);
                        }
                        else
                        {
                            List <string> value = new List <string>();
                            value.Add(col);
                            coltables.Add(name, value);
                        }
                    }
                }
                string pastname = "";
                foreach (string name in coltables.Keys)
                {
                    if (coltables[name].Count == 1)
                    {
                        string values = coltables[name][0];
                        string type   = values.Substring(0, 1);
                        if (type == "u" || type == "c" || type == "b" || type == "d")
                        {
                            string vcode = values.Substring(1, 2);
                            if (vcode == "00")
                            {
                                if (pastname != filename)
                                {
                                    Console.WriteLine(filename);
                                    pastname = filename;
                                }
                            }
                        }
                    }
                }
            }
        }