Ejemplo n.º 1
0
        public static List <DataMessage> Decrypt(string appDir, string gameDir, ProgressBar progressBar)
        {
            List <DataMessage> result  = new List <DataMessage>();
            double             percent = 0;

            ProgressBar(progressBar, (int)percent);
            string[] archives = Directory.GetFiles(gameDir, "*.XXX", SearchOption.AllDirectories)
                                .Where(file => ArchiveConfig.ArchiveName.Contains(Path.GetFileName(file))).ToArray();
            if (archives.Length > 0)
            {
                foreach (string archive in archives)
                {
                    List <DataMessage> messages = Sqex03DataMessage.Decrypt(File.ReadAllBytes(archive));
                    foreach (DataMessage message in messages)
                    {
                        if (!result.Any(item => item.Name == message.Name))
                        {
                            result.Add(message);
                        }
                    }
                    percent += 100.0 / archives.Length;
                    ProgressBar(progressBar, (int)percent);
                }
            }
            ProgressBar(progressBar, 100);
            return(result);
        }
Ejemplo n.º 2
0
        public static void Repack(string app_dir, string game_dir, List <DataMessage> data, ProgressBar progressBar)
        {
            List <string> archives = Directory.GetFiles(game_dir, "*.XXX", SearchOption.AllDirectories)
                                     .Where(file => ArchiveConfig.ArchiveName.Contains(Path.GetFileName(file))).ToList();
            List <string> tocs = Directory.GetFiles(game_dir, "*.txt", SearchOption.AllDirectories)
                                 .Where(file => ArchiveConfig.TOCName.Contains(Path.GetFileName(file))).ToList();

            if (archives.Count < 0)
            {
                return;
            }
            double percent = 0;
            Dictionary <string, string[]> tocContent = new Dictionary <string, string[]>();

            foreach (string toc in tocs)
            {
                tocContent.Add(Path.GetFileName(toc), File.ReadAllLines(toc));
            }
            foreach (string archive in archives)
            {
                byte[] bytes = Sqex03DataMessage.ReImport(data, archive);
                File.WriteAllBytes(archive, bytes);
                foreach (KeyValuePair <string, string[]> entry in tocContent)
                {
                    for (int i = 0; i < entry.Value.Length; i++)
                    {
                        string[] col = entry.Value[i].Split((char)32);
                        if (col.Length > 2 && col[2].Split((char)92).LastOrDefault().ToLower() == Path.GetFileName(archive).ToLower())
                        {
                            col[0]         = $"{bytes.Length}";
                            entry.Value[i] = String.Join(" ", col);
                        }
                    }
                }
                percent += 100.0 / archives.Count;
                ProgressBar(progressBar, (int)percent);
            }
            foreach (string toc in tocs)
            {
                string[] content;
                if (tocContent.TryGetValue(Path.GetFileName(toc), out content))
                {
                    File.WriteAllLines(toc, content);
                }
            }
            ProgressBar(progressBar, 100);
        }