示例#1
0
        public static void Pack(ServerMod sm)
        {
            string folderPath = Path.Combine(Program.Settings.GitDirectory, sm.GitPath);
            string modPath    = Path.Combine(Program.Settings.GitDirectory, sm.Name);

            if (sm.UseObfuSQF)
            {
                Console.WriteLine($"Running ObfuSQF for {sm.Name}\n");

                string obfuPath = Path.Combine(Program.Settings.ObfuSQFDirectory, "ObfuSQF_CMD.exe");
                string type     = sm.ObfuSQFMission ? "Mission" : "Mod";

                ProcessStartInfo obfu = new ProcessStartInfo(obfuPath);
                obfu.Arguments       = $"--token {Program.Settings.ObfuSQFToken} --input \"{folderPath}\" --type {type} --output \"{modPath}.pbo\"";
                obfu.UseShellExecute = false;
                obfu.CreateNoWindow  = true;

                ObfuProcs.Add(Process.Start(obfu));
            }
            else
            {
                Console.WriteLine($"Packing {sm.Name}\n");

                PboFile pbo = new PboFile();

                foreach (string s in Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories))
                {
                    string path = s.Replace(folderPath, "");

                    if (path.StartsWith(@"\"))
                    {
                        path = path.Substring(1);
                    }

                    string file = File.ReadAllText(s);

                    pbo.AddEntry(path, Encoding.UTF8.GetBytes(file));
                }

                pbo.Save($"{modPath}.pbo");
            }
        }
示例#2
0
        public static void Pack(ServerMod sm)
        {
            string gitName = Path.GetFileNameWithoutExtension(sm.GitUrl);

            string gitPath    = Path.Combine(Program.Settings.GitDirectory, gitName);
            string folderPath = Path.Combine(gitPath, sm.Name);
            string modPath    = Path.Combine(Program.Settings.GitDirectory, sm.Name);

            Console.WriteLine($"{folderPath} : {modPath}");



            if (sm.PackingMethod == PackingMethod.ObfuSQF)
            {
                Console.WriteLine($"Running ObfuSQF for {sm.Name}\n");

                string obfuPath = Path.Combine(Program.Settings.ObfuSQFDirectory, "ObfuSQF_CMD.exe");
                string type     = sm.ObfuSQFMission ? "Mission" : "Mod";

                ProcessStartInfo obfu = new ProcessStartInfo(obfuPath)
                {
                    Arguments       = $"--token {Program.Settings.ObfuSQFToken} --input \"{folderPath}\" --type {type} --output \"{modPath}.pbo\"",
                    UseShellExecute = false,
                    CreateNoWindow  = true
                };

                ObfuProcs.Add(Process.Start(obfu));
            }
            else if (sm.PackingMethod == PackingMethod.Normal)
            {
                Console.WriteLine($"Packing {sm.Name}\n");

                PboFile pbo = new PboFile();
                foreach (string s in Directory.GetFiles(folderPath, "*", SearchOption.AllDirectories))
                {
                    string filename = Path.GetFileName(s);
                    if (filename == "mission.sqm")
                    {
                        string Rapify = Path.Combine(Program.Settings.ToolsDirectory, "CfgConvert", "CfgConvert.exe");

                        if (File.Exists(Rapify) /*&& false*/)
                        {
                            Console.WriteLine("Binarising SQM");
                            Process.Start(new ProcessStartInfo
                            {
                                WorkingDirectory = folderPath,
                                FileName         = Rapify,
                                Arguments        = $"-bin {s}",
                                UseShellExecute  = false,
                                CreateNoWindow   = true
                            }).WaitForExit();
                        }
                    }

                    string path = s.Replace(folderPath, "");

                    if (path.StartsWith(@"\"))
                    {
                        path = path.Substring(1);
                    }

                    //string file = File.ReadAllText(s);

                    //pbo.AddEntry(path, Encoding.UTF8.GetBytes(file));

                    byte[] file = File.ReadAllBytes(s);

                    pbo.AddEntry(path, file);
                }

                pbo.Save($"{modPath}.pbo");
            }
            else if (sm.PackingMethod == PackingMethod.SqfSafe)
            {
                Console.WriteLine($"Running SqfSafe for {sm.Name}\n");

                string obfuPath = Path.Combine(Program.Settings.SqfSafeDirectory, "SqfSafe-CLI.exe");

                ProcessStartInfo obfu = new ProcessStartInfo(obfuPath)
                {
                    Arguments       = $"--token {Program.Settings.SqfSafeToken} -f \"{folderPath}\" -p \"{sm.SqfSafeProfile}\" -o \"{modPath}.pbo\"",
                    UseShellExecute = false,
                    CreateNoWindow  = true
                };

                ObfuProcs.Add(Process.Start(obfu));
            }
            else
            {
                Console.WriteLine($"Packing Method not Supported.");
                Util.Assert(false);
            }
        }