示例#1
0
        public void LoadFileDataComplete(CASCHandler casc)
        {
            if (!casc.FileExists("DBFilesClient\\FileDataComplete.db2"))
            {
                return;
            }

            Logger.WriteLine("WowRootHandler: loading file names from FileDataComplete.db2...");

            using (var s = casc.OpenFile("DBFilesClient\\FileDataComplete.db2"))
            {
                DB5Reader fd = new DB5Reader(s);

                foreach (var row in fd)
                {
                    string path = row.Value.GetField <string>(0);
                    string name = row.Value.GetField <string>(1);

                    string fullname = path + name;

                    ulong fileHash = Hasher.ComputeHash(fullname);

                    // skip invalid names
                    if (!RootData.ContainsKey(fileHash))
                    {
                        //Logger.WriteLine("Invalid file name: {0}", fullname);
                        continue;
                    }

                    CASCFile.Files[fileHash] = new CASCFile(fileHash, fullname);
                }
            }
        }
示例#2
0
        public int CompareTo(ICASCEntry other, int col, CASCHandler casc)
        {
            int result = 0;

            if (other is CASCFolder)
            {
                return(1);
            }

            switch (col)
            {
            case 0:
                result = Name.CompareTo(other.Name);
                break;

            case 1:
                result = Path.GetExtension(Name).CompareTo(Path.GetExtension(other.Name));
                break;

            case 2:
            {
                var e1     = casc.Root.GetEntries(Hash);
                var e2     = casc.Root.GetEntries(other.Hash);
                var flags1 = e1.Any() ? e1.First().LocaleFlags : LocaleFlags.None;
                var flags2 = e2.Any() ? e2.First().LocaleFlags : LocaleFlags.None;
                result = flags1.CompareTo(flags2);
            }
            break;

            case 3:
            {
                var e1     = casc.Root.GetEntries(Hash);
                var e2     = casc.Root.GetEntries(other.Hash);
                var flags1 = e1.Any() ? e1.First().ContentFlags : ContentFlags.None;
                var flags2 = e2.Any() ? e2.First().ContentFlags : ContentFlags.None;
                result = flags1.CompareTo(flags2);
            }
            break;

            case 4:
                var size1 = GetSize(casc);
                var size2 = (other as CASCFile).GetSize(casc);

                if (size1 == size2)
                {
                    result = 0;
                }
                else
                {
                    result = size1 < size2 ? -1 : 1;
                }
                break;
            }

            return(result);
        }
示例#3
0
        public OwRootHandler(BinaryReader stream, BackgroundWorkerEx worker, CASCHandler casc)
        {
            worker?.ReportProgress(0, "Loading \"root\"...");

            string str = Encoding.ASCII.GetString(stream.ReadBytes((int)stream.BaseStream.Length));

            string[] array = str.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            List <string> APMNames = new List <string>();

            for (int i = 1; i < array.Length; i++)
            {
                string[] filedata = array[i].Split('|');

                string name = filedata[4];

                if (Path.GetExtension(name) == ".apm" && name.Contains("RDEV"))
                {
                    APMNames.Add(Path.GetFileNameWithoutExtension(name));
                    if (!name.Contains("L" + LanguageScan))
                    {
                        continue;
                    }
                    // add apm file for dev purposes
                    ulong   apmNameHash = Hasher.ComputeHash(name);
                    MD5Hash apmMD5      = filedata[0].ToByteArray().ToMD5();
                    _rootData[apmNameHash] = new OWRootEntry()
                    {
                        baseEntry = new RootEntry()
                        {
                            MD5 = apmMD5, LocaleFlags = LocaleFlags.All, ContentFlags = ContentFlags.None
                        }
                    };

                    CASCFile.Files[apmNameHash] = new CASCFile(apmNameHash, name);

                    if (!casc.Encoding.GetEntry(apmMD5, out EncodingEntry apmEnc))
                    {
                        continue;
                    }

                    using (Stream apmStream = casc.OpenFile(apmEnc.Key))
                    {
                        apmFiles.Add(new APMFile(name, apmStream, casc));
                    }
                }

                worker?.ReportProgress((int)(i / (array.Length / 100f)));
            }
            APMList = APMNames.ToArray();
            APMNames.Clear();
        }
示例#4
0
        public int CompareTo(ICASCEntry other, int col, CASCHandler casc)
        {
            int result = 0;

            if (other is CASCFile)
            {
                return(-1);
            }

            switch (col)
            {
            case 0:
            case 1:
            case 2:
            case 3:
                result = Name.CompareTo(other.Name);
                break;

            case 4:
                break;
            }

            return(result);
        }
示例#5
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;

                if (!casc.Encoding.GetEntry(md5, out EncodingEntry 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");

            casc.Encoding.GetEntry(coreTocEntry.MD5, out EncodingEntry 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");

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

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

            worker?.ReportProgress(100);
        }
示例#6
0
 public long GetSize(CASCHandler casc) => casc.GetEncodingEntry(Hash, out EncodingEntry enc) ? enc.Size : 0;
示例#7
0
 public long GetSize(CASCHandler casc) => casc.GetFileSize(Hash);
示例#8
0
        public APMFile(string name, Stream stream, CASCHandler casc)
        {
            Name = name;

            using (BinaryReader reader = new BinaryReader(stream))
            {
                ulong buildVersion = reader.ReadUInt64();
                uint  buildNumber  = reader.ReadUInt32();
                uint  packageCount = reader.ReadUInt32();
                uint  entryCount   = reader.ReadUInt32();
                uint  unk          = reader.ReadUInt32();

                entries = new APMEntry[entryCount];

                for (int j = 0; j < entryCount; j++)
                {
                    entries[j] = reader.Read <APMEntry>();
                }

                packages     = new APMPackage[packageCount];
                indexes      = new PackageIndex[packageCount];
                records      = new PackageIndexRecord[packageCount][];
                dependencies = new uint[packageCount][];

                for (int j = 0; j < packages.Length; j++)
                {
                    packages[j] = reader.Read <APMPackage>();

                    if (!casc.Encoding.GetEntry(packages[j].indexContentKey, out EncodingEntry pkgIndexEnc))
                    {
                        throw new Exception("pkgIndexEnc missing");
                    }

                    using (Stream pkgIndexStream = casc.OpenFile(pkgIndexEnc.Key))
                        using (BinaryReader pkgIndexReader = new BinaryReader(pkgIndexStream))
                        {
                            indexes[j] = pkgIndexReader.Read <PackageIndex>();

                            pkgIndexStream.Position = indexes[j].recordsOffset;

                            using (GZipStream recordsStream = new GZipStream(pkgIndexStream, CompressionMode.Decompress, true))
                                using (BinaryReader recordsReader = new BinaryReader(recordsStream))
                                {
                                    PackageIndexRecord[] recs = new PackageIndexRecord[indexes[j].numRecords];

                                    for (int k = 0; k < recs.Length; k++)
                                    {
                                        recs[k] = recordsReader.Read <PackageIndexRecord>();
                                    }

                                    records[j] = recs;
                                }

                            pkgIndexStream.Position = indexes[j].depsOffset;

                            uint[] deps = new uint[indexes[j].numDeps];

                            for (int k = 0; k < deps.Length; k++)
                            {
                                deps[k] = pkgIndexReader.ReadUInt32();
                            }

                            dependencies[j] = deps;
                        }
                }
            }
        }