Exemple #1
0
 internal CDNClient(uint DepotID, Progress Progress, ProgressBar ProgressBar, SetStatusDelegate SetStatusMethod)
 {
     Log("Instance of CDN client created");
     ThreadsCount = DwThreadsCount;
     this.DepotID = DepotID;
     BaseURLs     = new string[ThreadsCount];
     Decryptors   = new Aes[ThreadsCount];
     WaitHandles  = new ManualResetEvent[ThreadsCount];
     for (int Iterator = 0; Iterator < ThreadsCount; Iterator++)
     {
         Aes Decryptor = Create();
         Decryptor.BlockSize   = 128;
         Decryptor.KeySize     = 256;
         Decryptors[Iterator]  = Decryptor;
         WaitHandles[Iterator] = new ManualResetEvent(false);
     }
     Initialize(ThreadsCount);
     for (int Iterator = 0; Iterator < ThreadsCount; Iterator++)
     {
         BaseURLs[Iterator] = $"https://{NextServer()}/depot/{this.DepotID = DepotID}/";
     }
     Log($"Picked {ThreadsCount} the least busy CDN servers");
     BaseDownloadPath = $@"{DownloadsDirectory}\{DepotID}";
     DepotKey         = DepotKeys[DepotID];
     this.Progress    = Progress;
     this.ProgressBar = ProgressBar;
     SetStatus        = SetStatusMethod;
     Decompressor     = new VZip(ThreadsCount);
 }
Exemple #2
0
        public static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Options:");
                Console.WriteLine("a [dir]  Copies all .hfs in the current directory to .zip");
                Console.WriteLine("h [file]  Convert .zip to .hfs");
                Console.WriteLine("z [file]  Convert .hfs to .zip");
                Console.WriteLine("r [hfs] [file] Add/Replace file to .hfs");
                Console.WriteLine("d [hfs] [name] Delete name to .hfs");
                return;
            }

            try
            {
                string cmd = args[0];
                if (cmd.StartsWith("-"))
                {
                    cmd = cmd.Substring(1);
                }
                switch (cmd)
                {
                case "a":
                {
                    string dir = Directory.GetCurrentDirectory();

                    if (args.Length > 1)
                    {
                        dir = args[1];
                    }

                    string[] files = Directory.GetFiles(dir, @"*.hfs");

                    foreach (string file in files)
                    {
                        VZip.ExtractHfs(file);
                    }
                }
                break;

                case "z":
                {
                    if (args.Length < 2)
                    {
                        return;
                    }

                    VZip.ExtractHfs(args[1]);
                }
                break;

                case "h":
                {
                    if (args.Length < 2)
                    {
                        return;
                    }

                    VZip.ConvertZip(args[1]);
                }
                break;

                case "r":
                {
                    if (args.Length < 3)
                    {
                        return;
                    }

                    VZip.AddOrReplace(args[1], args[2]);
                }
                break;

                case "d":
                {
                    if (args.Length < 3)
                    {
                        return;
                    }

                    VZip.Delete(args[1], args[2]);
                }
                break;

                default:
                    Console.WriteLine("Options:");
                    Console.WriteLine("a [dir]  Copies all .hfs in the current directory to .zip");
                    Console.WriteLine("h [file]  Convert .zip to .hfs");
                    Console.WriteLine("z [file]  Convert .hfs to .zip");
                    Console.WriteLine("r [hfs] [file] Add/Replace file to .hfs");
                    Console.WriteLine("d [hfs] [name] Delete name to .hfs");
                    break;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            Console.ReadKey();
        }
Exemple #3
0
        public bool CheckFiles(Form form)
        {
            IniHelper helper = new IniHelper(Program.INT_FILE);
            string    SEP    = "" + Path.PathSeparator;
            string    name   = null;
            bool      CN     = false;
            string    dir    = "";

            if (!File.Exists(textFile))
            {
                CN = SelectGameVer(out name);
                if (string.IsNullOrEmpty(name))
                {
                    return(false);
                }
                form.Info("请选择游戏目录");
                dir = SelectGamePath(CN);
                if (dir == null)
                {
                    return(false);
                }
                //查找本地已经存在的
                string deftext = PathHelper.Combine(dir, "resource", "localized_text", (CN?"chinese":"taiwan"), (CN?DEF_TEXT:DEF_TW));
                if (File.Exists(deftext))
                {
                    form.Info("找到翻译文件\n" + deftext);
                    helper.WriteValue("data", "text", deftext);
                    this.textFile = deftext;
                }
                else
                {
                    //解压
                    if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(dir, "hfs"), name, Application.StartupPath))
                    {
                        form.Info("找到翻译文件\n" + name);
                        helper.WriteValue("data", "text", name);
                        this.textFile = PathHelper.Combine(Application.StartupPath, name);
                    }
                    else
                    {
                        form.Info("没找到翻译文件\n" + name);
                        return(false);
                    }
                }
            }
            if (!File.Exists(dbFile))
            {
                if (string.IsNullOrEmpty(name))
                {
                    CN = SelectGameVer(out name);
                    if (string.IsNullOrEmpty(name))
                    {
                        return(false);
                    }
                    form.Info("请选择游戏目录");
                    dir = SelectGamePath(CN);
                    if (dir == null)
                    {
                        return(false);
                    }
                }
                string defdb = PathHelper.Combine(dir, "sql", DEF_DB);
                if (File.Exists(defdb))
                {
                    form.Info("找到数据库\n" + defdb);
                    helper.WriteValue("data", "heroes", defdb);
                    this.dbFile = defdb;
                }
                else
                {
                    //解压
                    if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(dir, "hfs"), DEF_DB, Application.StartupPath))
                    {
                        form.Info("找到数据库\n" + DEF_DB);
                        helper.WriteValue("data", "heroes", DEF_DB);
                        this.dbFile = DEF_DB;
                    }
                    else
                    {
                        form.Error("没找到数据库\n" + DEF_DB);
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #4
0
        public void TW2CN(string path)
        {
            //font
            Console.WriteLine("复制字体");
            string fontpath = PathHelper.Combine(path, "scaleform", "font");

            if (!Directory.Exists(fontpath))
            {
                Directory.CreateDirectory(fontpath);
            }
            string curfont = PathHelper.Combine(Application.StartupPath, "fonts_ch.swf");
            string cnfont  = PathHelper.Combine(fontpath, "fonts_ch.swf");

            if (!File.Exists(cnfont))
            {
                if (File.Exists(curfont))
                {
                    File.Copy(curfont, cnfont);
                }
                else
                {
                    if (!VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                                    "fonts_ch.swf",
                                                    fontpath))
                    {
                        if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                                       "fonts_tw.swf",
                                                       fontpath))
                        {
                            string text = PathHelper.Combine(fontpath, "fonts_tw.swf");
                            File.Move(text, cnfont);
                        }
                    }
                }
            }
            //db
            string textpath = PathHelper.Combine(path, "resource", "localized_text", "chinese");
            string cntext   = PathHelper.Combine(textpath, "heroes_text_chinese.txt");

            if (!File.Exists(cntext))
            {
                if (VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                               "heroes_text_taiwan.txt",
                                               textpath))
                {
                    string text = PathHelper.Combine(textpath, "heroes_text_taiwan.txt");

                    File.Delete(cntext);
                    File.Move(text, cntext);
                    TextTW2CN(cntext);
                }
            }
            Console.WriteLine("处理数据库");
            string dbpath = PathHelper.Combine(path, "sql");
            string cndb   = PathHelper.Combine(dbpath, "heroes.db3");

            if (!File.Exists(cndb))
            {
                if (!VZip.ExtractAllHfsFindFile(PathHelper.Combine(path, "hfs"),
                                                "heroes.db3", dbpath))
                {
                    return;
                }
            }
            if (File.Exists(cndb))
            {
                DbTW2CN(cndb);
            }
        }