static void Main() { Console.Title = "Arma Packer"; Console.WriteLine("Welcome to Arma Packer"); try { if (Directory.Exists(Settings.GitDirectory)) { Directory.Delete(Settings.GitDirectory, true); } Directory.CreateDirectory(Settings.GitDirectory); } catch (Exception ex) { Console.WriteLine("Invalid git directory provided! Config is invalid?"); Util.Assert(ex); } if (Settings.KillArmaServer) { Console.WriteLine("Ending Arma3Server processes"); if (Settings.Use64BitServer) { EndTask("arma3server_x64.exe"); } else { EndTask("arma3server.exe"); } } if (Settings.UseArmaRemoteAdmin) { Console.WriteLine("Ending ArmaRemoteAdmin processes"); EndTask("Maverick-ArmARemote.exe"); } Thread.Sleep(2000); foreach (string s in Settings.ObfLocalVars) { string newVar = "_" + Util.RandomString(Settings.RandomVarsLength); _localVars[s] = newVar; File.AppendAllText("variables.log", $"{s} => {newVar}\r\n"); } foreach (string s in Settings.ObfGlobalVars) { string newVar = Util.RandomString(Settings.RandomVarsLength); _globalVars[s] = newVar; File.AppendAllText("variables.log", $"{s} => {newVar}\r\n"); } foreach (string s in Settings.ObfFunctions) { string newFnc = Util.RandomString(Settings.RandomFuncsLength); string fnc = s.Replace(Settings.FunctionsTag + "_fnc_", ""); _scriptFuncs[fnc] = newFnc; File.AppendAllText("variables.log", $"{s} => {newFnc}\r\n"); } foreach (ServerMod sm in Settings.Mods) { Util.Assert(Util.GitDownload(sm), $"Downloading from git: {sm.Name}/{sm.GitUrl}"); RandomizeEverything(sm); FileEdit.Pack(sm); } foreach (ServerMod sm in Settings.Mods) { if (FileEdit.ObfuProcs.Count > 0) { Console.WriteLine("Waiting for ObfuSQF to finish..."); while (FileEdit.ObfuProcs.Count > 0) { List <Process> ps = new List <Process>(FileEdit.ObfuProcs); foreach (Process p in ps) { if (p.HasExited && FileEdit.ObfuProcs.Contains(p)) { FileEdit.ObfuProcs.Remove(p); } } Thread.Sleep(100); } Console.WriteLine("ObfuSQF finished."); } Util.Assert(FileEdit.Move(sm), "Failed to move files"); } if (Settings.UseArmaRemoteAdmin) { Console.WriteLine("All files moved."); Util.StartAra(); } else { //string serverName = Settings.Use64BitServer ? "arma3server_x64.exe" : "arma3server.exe"; //Process.Start(Settings.ServerDirectory + "/" + serverName); } Console.WriteLine("All done, goodbye!"); }
static void Main() { Console.Title = "Arma Packer"; Console.WriteLine("Welcome to Arma Packer"); try { DeleteDirectory(Settings.GitDirectory); Directory.CreateDirectory(Settings.GitDirectory); } catch (Exception ex) { Console.WriteLine("Invalid git directory provided! Config is invalid?"); Util.Assert(ex); } if (Settings.KillArmaServer) { Console.WriteLine("Ending Arma3Server processes"); if (Settings.Use64BitServer) { EndTask("arma3server_x64.exe"); } else { EndTask("arma3server.exe"); } } if (Settings.UseArmaRemoteAdmin) { Console.WriteLine("Ending ArmaRemoteAdmin processes"); EndTask("Maverick-ArmARemote.exe"); } //Thread.Sleep(2000); Console.WriteLine("Generating Random Vars"); foreach (string s in Settings.ObfLocalVars) { string newVar = "_" + Util.RandomString(Settings.RandomVarsLength); _localVars[s] = newVar; File.AppendAllText("variables.log", $"{s} => {newVar}\r\n"); } foreach (string s in Settings.ObfGlobalVars) { string newVar = Util.RandomString(Settings.RandomVarsLength); _globalVars[s] = newVar; _globalVars[$"{s}_HC"] = $"{newVar}_HC"; File.AppendAllText("variables.log", $"{s} => {newVar}\r\n"); } foreach (string s in Settings.ObfFunctions) { string newFnc = Util.RandomString(Settings.RandomFuncsLength); string fnc = s.Replace(Settings.FunctionsTag + "_fnc_", ""); _scriptFuncs[fnc] = newFnc; File.AppendAllText("variables.log", $"{s} => {newFnc}\r\n"); } foreach (ServerMod sm in Settings.Mods) { Util.Assert(Util.GitDownload(sm), $"Downloading from git: {sm.Name}/{sm.GitUrl}"); if (sm.ServerPath.EndsWith(".pbo")) { RandomizeEverything(sm); FileEdit.Pack(sm); } else { string gitName = Path.GetFileNameWithoutExtension(sm.GitUrl); string filePath = Path.Combine(Settings.GitDirectory, gitName, sm.Name); string modPath = Path.Combine(Settings.GitDirectory, Path.GetFileName(sm.Name)); if (!File.Exists(modPath)) { File.Copy(filePath, modPath); } } } foreach (ServerMod sm in Settings.Mods) { if (sm.ServerPath.EndsWith(".pbo")) { if (FileEdit.ObfuProcs.Count > 0) { Console.WriteLine("Waiting for ObfuSQF to finish..."); while (FileEdit.ObfuProcs.Count > 0) { List <Process> ps = new List <Process>(FileEdit.ObfuProcs); foreach (Process p in ps) { if (p.HasExited && FileEdit.ObfuProcs.Contains(p)) { FileEdit.ObfuProcs.Remove(p); } } Thread.Sleep(100); } Console.WriteLine("ObfuSQF finished."); } Util.Assert(FileEdit.Move(sm), "Failed to move files"); } else { Util.Assert(FileEdit.MoveFile(sm), "Failed to move files"); } } Console.WriteLine("All files moved."); if (Settings.UseArmaRemoteAdmin) { Util.StartAra(); } else if (Settings.StartArma) { string serverName = Settings.Use64BitServer ? "arma3server_x64.exe" : "arma3server.exe"; string armaServer = Path.Combine(Settings.ServerDirectory, serverName); //Process.Start(Settings.ServerDirectory + "/" + serverName); try { Process.Start(new ProcessStartInfo { WorkingDirectory = Program.Settings.GitDirectory, FileName = armaServer, Arguments = Settings.ServerParams }); Console.WriteLine($"Starting {serverName} with params\n {Settings.ServerParams}"); Thread.Sleep(2000); } catch (Exception ex) { Console.WriteLine($"Failed to start Arma Server. {ex.Message}"); Util.Assert(ex); }; } Console.WriteLine("All done, goodbye!"); }