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

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