예제 #1
0
        private static void Main(string[] args)
        {
            // Setup the handler for closing HES properly and saving
            HES._handler += new HES.EventHandler(HES.Handler);
            HES.SetConsoleCtrlHandler(HES._handler, true);

            // the GUI thread
            Thread uiThread = new Thread(LoadGUI);

            uiThread.SetApartmentState(ApartmentState.STA);
            //uiThread.Start(); Disabled for now!

            Console.Title = String.Format("HELLION EXTENDED SERVER V{0}) - Game Patch Version: {1} ", Version, "0.1.5");

            Console.WriteLine("Hellion Extended Server Initialized.");

            HES program = new HES(args);

            program.Run(args);
        }
예제 #2
0
        private static void Main(string[] args)
        {
            ThisProcess = Process.GetCurrentProcess();

            CommandLineArgs = args;
            Console.Title   = WindowTitle;

            new FolderStructure().Build();

            m_config  = new Config();
            debugMode = m_config.Settings.DebugMode;

            var path = Path.Combine(Environment.CurrentDirectory, "Newtonsoft.Json.dll");

            if (File.Exists(path))
            {
                try
                {
                    var name = AssemblyName.GetAssemblyName(path);

                    if (name.Version < new Version("10.0.0.0"))
                    {
                        using (Stream s = Assembly.GetCallingAssembly().GetManifestResourceStream("HellionExtendedServer.Resources.Newtonsoft.Json.dll"))
                        {
                            byte[] data = new byte[s.Length];
                            s.Read(data, 0, data.Length);

                            File.WriteAllBytes(path, data);
                        }
                    }
                }
                catch (Exception) { }
            }
            else
            {
                try
                {
                    using (Stream s = Assembly.GetCallingAssembly().GetManifestResourceStream("HellionExtendedServer.Resources.Newtonsoft.Json.dll"))
                    {
                        byte[] data = new byte[s.Length];
                        s.Read(data, 0, data.Length);

                        File.WriteAllBytes(path, data);
                    }
                }
                catch (Exception)
                {
                }
            }

            AppDomain.CurrentDomain.AssemblyResolve += (sender, rArgs) =>
            {
                string assemblyName = new AssemblyName(rArgs.Name).Name;
                if (assemblyName.EndsWith(".resources"))
                {
                    return(null);
                }

                string dllName     = assemblyName + ".dll";
                string dllFullPath = Path.Combine(Path.GetFullPath("Hes\\bin"), dllName);

                if (dllName == "Newtonsoft.Json.dll")
                {
                    try
                    {
                        if (new AssemblyName(rArgs.Name).Version < new Version("10.0.0.0"))
                        {
                            using (Stream s = Assembly.GetCallingAssembly().GetManifestResourceStream("HellionExtendedServer.Resources.Newtonsoft.Json.dll"))
                            {
                                byte[] data = new byte[s.Length];
                                s.Read(data, 0, data.Length);

                                File.WriteAllBytes(path, data);
                            }
                            return(Assembly.LoadFrom(path));
                        }
                    }
                    catch (Exception)
                    {
                    }
                }

                if (debugMode)
                {
                    Console.WriteLine($"The assembly '{dllName}' is missing or has been updated. Adding/Updating missing assembly.");
                }

                using (Stream s = Assembly.GetCallingAssembly().GetManifestResourceStream("HellionExtendedServer.Resources." + dllName))
                {
                    byte[] data = new byte[s.Length];
                    s.Read(data, 0, data.Length);

                    File.WriteAllBytes(dllFullPath, data);
                }

                return(Assembly.LoadFrom(dllFullPath));
            };

            // This is for args that should be used before HES loads
            bool noUpdateHes           = false;
            bool noUpdateHellion       = false;
            bool usePrereleaseVersions = false;

            Console.ForegroundColor = ConsoleColor.Green;
            foreach (string arg in args)
            {
                if (arg.Equals("-noupdatehes"))
                {
                    noUpdateHes = true;
                }

                if (arg.Equals("-noupdatehellion"))
                {
                    noUpdateHellion = true;
                }

                if (arg.Equals("-usedevversion"))
                {
                    usePrereleaseVersions = true;
                }
            }

            if (usePrereleaseVersions || Config.Settings.EnableDevelopmentVersion)
            {
                Console.WriteLine("HellionExtendedServer: (Arg: -usedevversion is set) HES Will use Pre-releases versions");
            }

            if (noUpdateHes || !Config.Settings.EnableAutomaticUpdates)
            {
                UpdateManager.EnableAutoUpdates = false;
                Console.WriteLine("HellionExtendedServer: (Arg: -noupdatehes is set or option in HES config is enabled) HES will not be auto-updated.\r\n");
            }

            if (noUpdateHellion || !Config.Settings.EnableHellionAutomaticUpdates)
            {
                SteamCMD.AutoUpdateHellion = false;
                Console.WriteLine("HellionExtendedServer: (Arg: -noupdatehellion is set) Hellion Dedicated will not be auto-updated.");
            }

            Console.ResetColor();

            updateManager = new UpdateManager();

            var program = new HES(args);

            program.Run(args);
        }