Esempio n. 1
0
        public int CompareTo(ICASCEntry other, int col, CASCEngine 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.RootHandler.GetEntries(Hash);
                var e2 = casc.RootHandler.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.RootHandler.GetEntries(Hash);
                var e2 = casc.RootHandler.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);
        }
Esempio n. 2
0
        private BinaryReader OpenInstallationFile(EncodingHandler encoding, CASCEngine engine, MD5Hash hash, string errorName)
        {
            EncodingEntry entry;

            if (!encoding.GetEntry(hash, out entry))
            {
                throw new FileNotFoundException(string.Format("Installation missing {0} file!", errorName));
            }

            return(new BinaryReader(engine.OpenFile(entry.Key)));
        }
Esempio n. 3
0
        public int CompareTo(ICASCEntry other, int col, CASCEngine 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.RootHandler.GetEntries(Hash);
                        var e2 = casc.RootHandler.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.RootHandler.GetEntries(Hash);
                        var e2 = casc.RootHandler.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;
        }
Esempio n. 4
0
        public int CompareTo(ICASCEntry other, int col, CASCEngine 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;
        }
Esempio n. 5
0
        public int CompareTo(ICASCEntry other, int col, CASCEngine 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);
        }
Esempio n. 6
0
        public void LoadFileDataComplete(CASCEngine casc)
        {
            string dbFileDataComplete = "DBFilesClient\\FileDataComplete.db2";
            if (!casc.FileExists(dbFileDataComplete))
                return;

            Log.Write("CASC: Loading entries from FileDataComplete (DB2)");

            using (var stream = casc.OpenFile(dbFileDataComplete))
            {
                DB5_Reader db = new DB5_Reader(stream);
                foreach (var row in db)
                {
                    string path = row.Value.GetField<string>(0);
                    string name = row.Value.GetField<string>(1);

                    string fullName = path + name;
                    ulong fileHash = Hasher.ComputeHash(fullName);

                    if (!RootData.ContainsKey(fileHash))
                        continue;

                    CASCFile.FileNames[fileHash] = fullName;
                }
            }
        }
Esempio n. 7
0
 private BinaryReader OpenEncodingFile(CASCEngine casc)
 {
     return new BinaryReader(casc.OpenFile(casc.Config.EncodingKey));
 }
Esempio n. 8
0
        private BinaryReader OpenInstallationFile(EncodingHandler encoding, CASCEngine engine, MD5Hash hash, string errorName)
        {
            EncodingEntry entry;

            if (!encoding.GetEntry(hash, out entry))
                throw new FileNotFoundException(string.Format("Installation missing {0} file!", errorName));

            return new BinaryReader(engine.OpenFile(entry.Key));
        }
Esempio n. 9
0
 private BinaryReader OpenRootFile(EncodingHandler encoding, CASCEngine casc)
 {
     return OpenInstallationFile(encoding, casc, casc.Config.RootMD5, "root");
 }
Esempio n. 10
0
 private BinaryReader OpenInstallFile(EncodingHandler encoding, CASCEngine casc)
 {
     return OpenInstallationFile(encoding, casc, casc.Config.InstallMD5, "install");
 }
Esempio n. 11
0
 private BinaryReader OpenEncodingFile(CASCEngine casc)
 {
     return(new BinaryReader(casc.OpenFile(casc.Config.EncodingKey)));
 }
Esempio n. 12
0
 private BinaryReader OpenRootFile(EncodingHandler encoding, CASCEngine casc)
 {
     return(OpenInstallationFile(encoding, casc, casc.Config.RootMD5, "root"));
 }
Esempio n. 13
0
 private BinaryReader OpenDownloadFile(EncodingHandler encoding, CASCEngine casc)
 {
     return(OpenInstallationFile(encoding, casc, casc.Config.DownloadMD5, "download"));
 }
Esempio n. 14
0
 private BinaryReader OpenInstallFile(EncodingHandler encoding, CASCEngine casc)
 {
     return(OpenInstallationFile(encoding, casc, casc.Config.InstallMD5, "install"));
 }
Esempio n. 15
0
 public int GetSize(CASCEngine casc)
 {
     EncodingEntry entry;
     return casc.GetEncodingEntry(hash, out entry) ? entry.Size : 0;
 }
Esempio n. 16
0
 private BinaryReader OpenDownloadFile(EncodingHandler encoding, CASCEngine casc)
 {
     return OpenInstallationFile(encoding, casc, casc.Config.DownloadMD5, "download");
 }
Esempio n. 17
0
        public int GetSize(CASCEngine casc)
        {
            EncodingEntry entry;

            return(casc.GetEncodingEntry(hash, out entry) ? entry.Size : 0);
        }