// this is where stuff goes! private void Run(string[] args) { mainLog = LogManager.GetCurrentClassLogger(); m_localization = new Localization(); m_localization.Load(m_config.Settings.CurrentLanguage.ToString().Substring(0, 2)); //Build IR's paths so we can use the Localization system Game.Program.InitFileSystems(); Game.Program.InitGameDirectory("InterstellarRift"); //new ServerConfigConverter().BuildAndUpdateConfigProperties(); // They initialize it as (string[])null, not good for us trying to use their static classes, this fixes it Game.Program.CommandLineArgs = new string[1]; bool autoStart = Config.Settings.AutoStartEnable; Console.ForegroundColor = ConsoleColor.Green; foreach (string arg in args) { if (arg.Equals("-nogui")) { m_useGui = false; if (!m_form.Visible) { Console.WriteLine("IRSE: (Arg: -nogui is set) GUI Disabled, use /showgui to Enable it for this session."); } } autoStart = arg.Equals("-autostart"); } Console.ResetColor(); if (!Environment.UserInteractive) { Console.WriteLine("Non interactive environment detected, GUI disabled"); } else if (m_useGui) { SetupGUI(); } Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("IRSE: Ready for Input, try /help !"); if (autoStart) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("IRSE: Arg: -autostart or Gui's Autostart Checkbox was Checked)"); Console.ResetColor(); ServerInstance.Instance.Start(); } Console.ResetColor(); //console logic for commands ReadConsoleCommands(args); }
private static void Main(string[] args) { CommandLineArgs = args.ToList(); new FolderStructure().Build(); SetTitle(); SteamCMD.PasswordEncoder = new PasswordEncoder(); m_config = new Config(); debugMode = m_config.Settings.DebugMode; m_localization = new Localization(); m_localization.Load(m_config.Settings.CurrentLanguage); AppDomain.CurrentDomain.AssemblyResolve += (sender, rArgs) => { Assembly executingAssembly = Assembly.GetExecutingAssembly(); AssemblyName assemblyName = new AssemblyName(rArgs.Name); var pathh = assemblyName.Name + ".dll"; if (assemblyName.CultureInfo != null && assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false) { pathh = String.Format(@"{0}\{1}", assemblyName.CultureInfo, pathh); } // get binaries in plugins String modPath = Path.Combine(FolderStructure.IRSEFolderPath, "plugins"); String[] subDirectories = Directory.GetDirectories(modPath); foreach (String subDirectory in subDirectories) { string path = Path.Combine(Path.GetFullPath(FolderStructure.IRSEFolderPath), "plugins", subDirectory, pathh); if (File.Exists(path)) { return(Assembly.LoadFrom(path)); } // maybe a subfolder? foreach (String subDirectory2 in Directory.GetDirectories(subDirectory)) { string path2 = Path.Combine(Path.GetFullPath(FolderStructure.IRSEFolderPath), "plugins", subDirectory2, "bin", pathh); if (File.Exists(path2)) { return(Assembly.LoadFrom(path2)); } } } pathh = "IRSE.Resources." + pathh; using (Stream stream = executingAssembly.GetManifestResourceStream(pathh)) { if (stream == null) { return(null); } var assemblyRawBytes = new byte[stream.Length]; stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length); //Console.WriteLine("found missing dll: " + pathh); return(Assembly.Load(assemblyRawBytes)); } }; if (Program.Localization.Sentences.Count == 0) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Missing Language Resources! Please make sure all files are installed!"); Console.WriteLine("Press any key to Quit."); Console.ReadKey(true); Environment.Exit(0); } Console.WriteLine(string.Format(Program.Localization.Sentences["Initialization"], Version)); Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine($"Repo URL: {ThisAssembly.Git.RepositoryUrl}"); Console.WriteLine($"Git Branch: {ThisAssembly.Git.Branch}"); if (Dev) { Console.WriteLine($"Git Commit Date: {ThisAssembly.Git.CommitDate}"); Console.WriteLine($"Git Commit: {ThisAssembly.Git.Commit}"); Console.WriteLine($"Git SHA: {ThisAssembly.Git.Sha}"); } Console.WriteLine(); if (args.Contains("-noupdateir") || !Config.Settings.EnableAutomaticUpdates) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(string.Format(Program.Localization.Sentences["NoUpdateIR"])); } //else //new SteamCMD().GetSteamCMD(); if (!File.Exists(Path.Combine(FolderStructure.RootFolderPath, "IR.exe"))) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(string.Format(Program.Localization.Sentences["IRNotFound"])); Console.ReadLine(); Environment.Exit(0); } Instance = new Program(); Instance.Run(args); }