예제 #1
0
        void StartupThread()
        {
#if !DEBUG
            try {
#endif
            Server.InitLibrary(Environment.GetCommandLineArgs());
            if (shutdownPending)
            {
                return;
            }

            Server.InitServer();
            if (shutdownPending)
            {
                return;
            }

            BeginInvoke((Action)OnInitSuccess);

            // check for updates
            UpdaterMode updaterMode = ConfigKey.UpdaterMode.GetEnum <UpdaterMode>();
            if (updaterMode != UpdaterMode.Disabled)
            {
                UpdaterResult update = Updater.CheckForUpdates();
                if (shutdownPending)
                {
                    return;
                }
                if (update.UpdateAvailable)
                {
                    if (updaterMode == UpdaterMode.Notify)
                    {
                        String updateMsg = String.Format("An fCraft update is available! Visit www.fCraft.net to download. " +
                                                         "Local version: {0}. Latest available version: {1}.",
                                                         Updater.CurrentRelease.VersionString,
                                                         update.LatestRelease.VersionString);
                        Logger.LogToConsole(updateMsg);
                    }
                    else
                    {
                        DialogResult result = new UpdateWindow(update).ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            // startup aborted (restart for update)
                            return;
                        }
                    }
                }
            }

            // set process priority
            if (!ConfigKey.ProcessPriority.IsBlank())
            {
                try {
                    Process.GetCurrentProcess().PriorityClass = ConfigKey.ProcessPriority.GetEnum <ProcessPriorityClass>();
                } catch (Exception) {
                    Logger.Log(LogType.Warning,
                               "MainForm.StartServer: Could not set process priority, using defaults.");
                }
            }

            if (shutdownPending)
            {
                return;
            }
            if (Server.StartServer())
            {
                startupComplete = true;
                BeginInvoke((Action)OnStartupSuccess);
            }
            else
            {
                BeginInvoke((Action)OnStartupFailure);
            }
#if !DEBUG
        }

        catch (Exception ex) {
            Logger.LogAndReportCrash("Unhandled exception in ServerGUI.StartUp", "ServerGUI", ex, true);
            Shutdown(ShutdownReason.Crashed);
        }
#endif
        }
예제 #2
0
        void StartupThread()
        {
            #if !DEBUG
            try {
            #endif
                Server.InitLibrary( Environment.GetCommandLineArgs() );
                if ( shutdownPending ) return;

                Server.InitServer();
                if ( shutdownPending ) return;

                BeginInvoke( ( Action )OnInitSuccess );

                // check for updates
                UpdaterMode updaterMode = ConfigKey.UpdaterMode.GetEnum<UpdaterMode>();
                if ( updaterMode != UpdaterMode.Disabled ) {
                    if ( shutdownPending ) return;
                    if ( Updater.UpdateCheck() ) {
                        if ( updaterMode == UpdaterMode.Notify ) {
                            String updateMsg = String.Format( "An AtomicCraft update is available! Visit http://github.com/glennmr/AtomicCraft/downloads to download. " +
                                                              "Local version: {0}. Latest available version: {1}.",
                                                              Updater.CurrentRelease.VersionString,
                                                              Updater.WebVersionFullString );
                            Logger.LogToConsole( updateMsg );
                        } else {
                            DialogResult result = new UpdateWindow().ShowDialog();
                            if ( result == DialogResult.Cancel ) {
                                // startup aborted (restart for update)
                                return;
                            }
                        }
                    }
                }

                // set process priority
                if ( !ConfigKey.ProcessPriority.IsBlank() ) {
                    try {
                        Process.GetCurrentProcess().PriorityClass = ConfigKey.ProcessPriority.GetEnum<ProcessPriorityClass>();
                    } catch ( Exception ) {
                        Logger.Log( LogType.Warning,
                                    "MainForm.StartServer: Could not set process priority, using defaults." );
                    }
                }

                if ( shutdownPending ) return;
                if ( Server.StartServer() ) {
                    startupComplete = true;
                    BeginInvoke( ( Action )OnStartupSuccess );
                } else {
                    BeginInvoke( ( Action )OnStartupFailure );
                }
            #if !DEBUG
            } catch ( Exception ex ) {
                Logger.LogAndReportCrash( "Unhandled exception in ServerGUI.StartUp", "ServerGUI", ex, true );
                Shutdown( ShutdownReason.Crashed, Server.HasArg( ArgKey.ExitOnCrash ) );
            }
            #endif
        }