Пример #1
0
 public override void Clear()
 {
     RootData.Clear();
     D3RootData.Clear();
     tocParser = null;
     pkgParser = null;
     CASCFile.FileNames.Clear();
 }
Пример #2
0
 public override void Clear()
 {
     RootData.Clear();
     D3RootData.Clear();
     tocParser = null;
     pkgParser = null;
     CASCFile.FileNames.Clear();
 }
Пример #3
0
        public D3RootHandler(BinaryReader stream, BackgroundWorkerEx worker, CASCHandler casc)
        {
            worker?.ReportProgress(0, "Loading \"root\"...");

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            byte b3 = stream.ReadByte();
            byte b4 = stream.ReadByte();

            int count = stream.ReadInt32();

            for (int j = 0; j < count; j++)
            {
                MD5Hash md5 = stream.Read<MD5Hash>();
                string name = stream.ReadCString();

                var entries = new List<D3RootEntry>();
                D3RootData[name] = entries;

                EncodingEntry enc;

                if (!casc.Encoding.GetEntry(md5, out enc))
                    continue;

                using (BinaryReader s = new BinaryReader(casc.OpenFile(enc.Key)))
                {
                    uint magic = s.ReadUInt32();

                    int nEntries0 = s.ReadInt32();

                    for (int i = 0; i < nEntries0; i++)
                    {
                        entries.Add(D3RootEntry.Read(0, s));
                    }

                    int nEntries1 = s.ReadInt32();

                    for (int i = 0; i < nEntries1; i++)
                    {
                        entries.Add(D3RootEntry.Read(1, s));
                    }

                    int nNamedEntries = s.ReadInt32();

                    for (int i = 0; i < nNamedEntries; i++)
                    {
                        entries.Add(D3RootEntry.Read(2, s));
                    }
                }

                worker?.ReportProgress((int)((j + 1) / (float)(count + 2) * 100));
            }

            // Parse CoreTOC.dat
            var coreTocEntry = D3RootData["Base"].Find(e => e.Name == "CoreTOC.dat");

            EncodingEntry enc1;
            casc.Encoding.GetEntry(coreTocEntry.MD5, out enc1);

            using (var file = casc.OpenFile(enc1.Key))
                tocParser = new CoreTOCParser(file);

            worker?.ReportProgress((int)((count + 1) / (float)(count + 2) * 100));

            // Parse Packages.dat
            var pkgEntry = D3RootData["Base"].Find(e => e.Name == "Data_D3\\PC\\Misc\\Packages.dat");

            EncodingEntry enc2;
            casc.Encoding.GetEntry(pkgEntry.MD5, out enc2);

            using (var file = casc.OpenFile(enc2.Key))
                pkgParser = new PackagesParser(file);

            worker?.ReportProgress(100);
        }
Пример #4
0
        public D3RootHandler(BinaryReader stream, BackgroundWorkerEx worker, CASCHandler casc)
        {
            worker?.ReportProgress(0, "Loading \"root\"...");

            byte b1 = stream.ReadByte();
            byte b2 = stream.ReadByte();
            byte b3 = stream.ReadByte();
            byte b4 = stream.ReadByte();

            int count = stream.ReadInt32();

            for (int j = 0; j < count; j++)
            {
                byte[] md5  = stream.ReadBytes(16);
                string name = stream.ReadCString();

                var entries = new List <D3RootEntry>();
                D3RootData[name] = entries;

                EncodingEntry enc = casc.Encoding.GetEntry(md5);

                using (BinaryReader s = new BinaryReader(casc.OpenFile(enc.Key)))
                {
                    if (s != null)
                    {
                        uint magic = s.ReadUInt32();

                        int nEntries0 = s.ReadInt32();

                        for (int i = 0; i < nEntries0; i++)
                        {
                            entries.Add(D3RootEntry.Read(0, s));
                        }

                        int nEntries1 = s.ReadInt32();

                        for (int i = 0; i < nEntries1; i++)
                        {
                            entries.Add(D3RootEntry.Read(1, s));
                        }

                        int nNamedEntries = s.ReadInt32();

                        for (int i = 0; i < nNamedEntries; i++)
                        {
                            entries.Add(D3RootEntry.Read(2, s));
                        }
                    }
                }

                worker?.ReportProgress((int)((j + 1) / (float)(count + 2) * 100));
            }

            // Parse CoreTOC.dat
            var coreTocEntry = D3RootData["Base"].Find(e => e.Name == "CoreTOC.dat");

            EncodingEntry enc1 = casc.Encoding.GetEntry(coreTocEntry.MD5);

            using (var file = casc.OpenFile(enc1.Key))
                tocParser = new CoreTOCParser(file);

            worker?.ReportProgress((int)((count + 1) / (float)(count + 2) * 100));

            // Parse Packages.dat
            var pkgEntry = D3RootData["Base"].Find(e => e.Name == "Data_D3\\PC\\Misc\\Packages.dat");

            EncodingEntry enc2 = casc.Encoding.GetEntry(pkgEntry.MD5);

            using (var file = casc.OpenFile(enc2.Key))
                pkgParser = new PackagesParser(file);

            worker?.ReportProgress(100);
        }