Esempio n. 1
0
        internal static void Main(string[] arguments)
        {
            Console.Title = "Bluedot Habbo Server";

            Console.WriteLine("Bluedot Habbo Server - Preparing...");

            #region Exit management
            Console.WriteLine("Disabling close window button...");
            // Disable close button to prevent unsafe closing.
            IntPtr current = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
            EnableMenuItem(GetSystemMenu(current, false), SC_CLOSE, MF_GRAYED);

            Console.WriteLine("Binding shutdown to CTRL + C and CTRL + Break...");
            // Reassign CTRL+C and CTRL+BREAK to safely shutdown.
            Console.TreatControlCAsInput = false;
            Console.CancelKeyPress      += ShutdownKey;
            #endregion


            Thread.CurrentThread.Name = "BLUEDOT-EntryThread";

            Console.WriteLine("Setting up packaged reference loading...");
            // Allows embedded resources to be loaded.
            AppDomain.CurrentDomain.AssemblyResolve += LoadPackagedReferences;

            Console.WriteLine("Setting up fatel exception handler (BSOD style)...");
            // Bluescreen in the event of a fatal unhandled exception.
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;


            string configFile = Path.Combine(Environment.CurrentDirectory, "config.xml");

            Console.WriteLine("Parsing command line arguments...");
            Regex nameValueRegex = new Regex("^--(?<name>[\\w-]+)=(?<value>.+)$");

            foreach (string argument in arguments)
            {
                Match  nameValueMatch = nameValueRegex.Match(argument);
                string name           = nameValueMatch.Groups["name"].Value;
                string value          = nameValueMatch.Groups["value"].Value;

                Console.WriteLine("  " + name + " - " + value);

                switch (name)
                {
                case "config-file":
                {
                    configFile = value;
                    break;
                }

                case "bsod-wait":
                {
                    _waitOnBsod = true;
                    break;
                }

                default:
                {
                    Console.WriteLine("Unknown command line argument (" + name + "=" + value + ")");
                    break;
                }
                }
            }
            Console.WriteLine("Config location: " + configFile);
            Environment.SetEnvironmentVariable("BLUEDOT_CONFIG_PATH", configFile);

            Console.WriteLine("Preparing installer core...");
            CoreManager.InitialiseInstallerCore();

            Console.WriteLine("Preparing server core...");
            CoreManager.InitialiseServerCore();

            Console.WriteLine("Starting server core...");
            CoreManager.ServerCore.Boot();
        }
Esempio n. 2
0
        public static void Main(string[] arguments)
        {
            Thread.CurrentThread.Name = "IHI-EntryThread";
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;

            UnixAware.UnixMode = false;
            switch (Environment.OSVersion.Platform)
            {
            case PlatformID.Unix:
            case PlatformID.MacOSX:
            {
                UnixAware.UnixMode = true;
                break;
            }
            }


            string configFile      = "config.xml";
            bool   disableAutoExit = false;

            Regex nameValueRegex = new Regex("^--(?<name>[\\w-]+)=(?<value>.+)$");

            foreach (string argument in arguments)
            {
                Match  nameValueMatch = nameValueRegex.Match(argument);
                string name           = nameValueMatch.Groups["name"].Value;
                string value          = nameValueMatch.Groups["value"].Value;

                switch (name)
                {
                case "config-file":
                {
                    configFile = value;
                    break;
                }

                case "auto-exit":
                {
                    switch (value.ToLower())
                    {
                    case "false":
                    case "off":
                    case "no":
                    case "disable":
                    case "disabled":
                        disableAutoExit = true;
                        break;
                    }
                    break;
                }
                }
            }

            if (!UnixAware.UnixMode)
            {
                if (Type.GetType("Mono.Runtime") == null)
                {
                    Console.Title = "IHI [Windows] [.NET] | V" +
                                    Assembly.GetExecutingAssembly().GetName().Version.ToString(4);
                    Console.WriteLine("\n    IHI [Windows] [.NET] | V" +
                                      Assembly.GetExecutingAssembly().GetName().Version.ToString(4) + "\n");
                }
                else
                {
                    Console.Title = "IHI [Windows] [Mono] | V" +
                                    Assembly.GetExecutingAssembly().GetName().Version.ToString(4);
                    Console.WriteLine("\n    IHI [Windows] [Mono] | V" +
                                      Assembly.GetExecutingAssembly().GetName().Version.ToString(4) + "\n");
                }
            }
            else
            {
                Console.Title = "IHI [Unix] [Mono] | V" + Assembly.GetExecutingAssembly().GetName().Version.ToString(4);
                Console.WriteLine("\n    IHI [Unix] [Mono] | V" +
                                  Assembly.GetExecutingAssembly().GetName().Version.ToString(4) + "\n");
            }

            Console.Beep();

            CoreManager.InitialiseServerCore();
            CoreManager.InitialiseInstallerCore();

            BootResult bootResult = CoreManager.ServerCore.Boot(Path.Combine(Environment.CurrentDirectory, configFile));

            CoreManager.DereferenceInstallerCore();
            GC.Collect();

            if (bootResult != BootResult.AllClear)
            {
                Console.WriteLine("\n\n\n    IHI has failed to boot!");

                if (disableAutoExit)
                {
                    Console.WriteLine("\n\n    Auto Exit Disabled - Press any key to exit!");
                    Console.ReadKey(true);
                }
                return;
            }

            // Reassign CTRL + C to safely shutdown.
            // CTRL + Break is still unsafe.
            Console.TreatControlCAsInput = false;
            Console.CancelKeyPress      += ShutdownKey;

            while (true)
            {
                // Block all future input
                Console.ReadKey(true);
            }
        }
Esempio n. 3
0
        internal static void Main(string[] arguments)
        {
            entryForeground = System.Console.ForegroundColor;
            entryBackground = System.Console.BackgroundColor;

            System.Console.Title = "Bluedot Habbo Server";

            System.Console.WriteLine("Bluedot Habbo Server - Preparing...");

            #region Exit management
            System.Console.WriteLine("Disabling close window button...");
            // Disable close button to prevent unsafe closing.
            SetExitButtonEnabled(false);

            System.Console.WriteLine("Binding shutdown to CTRL + C and CTRL + Break...");
            // Reassign CTRL+C and CTRL+BREAK to safely shutdown.
            System.Console.CancelKeyPress      += HandleShutdownKey;
            System.Console.TreatControlCAsInput = false;
            SetShutdownKeyMode(ShutdownKeyMode.AttemptShutdown);
            #endregion


            Thread.CurrentThread.Name = "BLUEDOT-EntryThread";

            System.Console.WriteLine("Setting up packaged reference loading...");
            // Allows embedded resources to be loaded.
            AppDomain.CurrentDomain.AssemblyResolve += LoadPackagedReferences;

            System.Console.WriteLine("Setting up fatal exception handler (BSOD style)...");
            // Bluescreen in the event of a fatal unhandled exception.
            AppDomain.CurrentDomain.UnhandledException += UnhandledException;


            string configFile = Path.Combine(Environment.CurrentDirectory, "config.xml");

            System.Console.WriteLine("Parsing command line arguments...");
            Regex nameValueRegex = new Regex("^--(?<name>[\\w-]+)=(?<value>.+)$");

            foreach (string argument in arguments)
            {
                Match  nameValueMatch = nameValueRegex.Match(argument);
                string name           = nameValueMatch.Groups["name"].Value;
                string value          = nameValueMatch.Groups["value"].Value;

                System.Console.WriteLine("  " + name + " - " + value);

                switch (name)
                {
                case "config-file":
                {
                    configFile = value;
                    break;
                }

                case "basic-console":
                {
                    Environment.SetEnvironmentVariable("IHI_BASIC_INSTALLER", value);
                    break;
                }

                default:
                {
                    System.Console.WriteLine("Unknown command line argument (" + name + "=" + value + ")");
                    break;
                }
                }
            }
            System.Console.WriteLine("Config location: " + configFile);
            Environment.SetEnvironmentVariable("IHI_CONFIG_PATH", configFile);

            if (Environment.GetEnvironmentVariable("IHI_BASIC_INSTALLER") == "true")
            {
                System.Console.WriteLine("Basic Console Mode! The installer will not be used and will instead generate a config file filled with default values!");
            }


            System.Console.WriteLine("Preparing server core...");
            CoreManager.InitialiseServerCore();

            System.Console.WriteLine("Starting server core...");

            try
            {
                CoreManager.ServerCore.Boot();
            }
            catch (Exception e)
            {
                Crash(e);
            }
        }