Beispiel #1
0
        private static void handleException(Exception e, bool exit = true)
        {
            if (e is BadImageFormatException && handleBadImageFormat(e as BadImageFormatException))
            {
                return;
            }

            if (e is NoGLContextAvailable) // || e is System.ComponentModel.Win32Exception)
            {
                //return user to stable for now.
                try
                {
                    Configuration.ConfigManager.sReleaseStream.Value = ReleaseStream.Stable;
                    Configuration.ConfigManager.SaveConfig();
                }
                catch { }
                Repair(false, e);
            }

            var typeInitException = e as TypeInitializationException;

            if (typeInitException != null)
            {
                Repair(true, typeInitException);
            }

            GameBase.Scheduler.Add(delegate
            {
                GameBase.MenuActive = true;

                ErrorDialog dialog = new ErrorDialog(e, true);
                dialog.ShowDialog();

                if (exit)
                {
                    BanchoClient.Exit();
                    Environment.Exit(-1);
                }
                else
                {
                    GameBase.MenuActive = false;
                }
            });

            while (exit)
            {
                Thread.Sleep(60000);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This code is run in a separate method as it *requires* XNA framework.
        /// Anything before this point can be executed without XNA present (updater etc.)
        /// </summary>
        private static void runGame(string fileArgs, bool isTournamentManager, bool isDrawings)
        {
            if (fileArgs != null && fileArgs.StartsWith(@"-"))
            {
                fileArgs = null;
            }

#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += (s, e) => handleException(e.ExceptionObject as Exception, true);
            Application.ThreadException += (s, e) => handleException(e.Exception, false);
#endif

            GameBase.CheckForUpdates();

            try
            {
                if (isTournamentManager || isDrawings)
                {
                    GameBase.Tournament        = true;
                    GameBase.TournamentManager = true;
                    GameBase.QueuedMode        = OsuModes.Tourney;

                    allowSplashScreen = false;
                }

                if (TabletHandler.IsRunningInTabletMode)
                {
                    allowSplashScreen = false;
                }

                if (isDrawings)
                {
                    GameBase.TournamentDrawings = true;
                    GameBase.QueuedMode         = OsuModes.SelectDrawings;
                }

                showSplash();

                Started = true;

                using (Process currentProcess = Process.GetCurrentProcess())
                {
                    currentProcess.PriorityBoostEnabled = true;
                    currentProcess.PriorityClass        = ProcessPriorityClass.High;
                }

                using (TimePeriod p = new TimePeriod(1))
                    new GameBase(fileArgs).Run();
            }
            catch (MissingManifestResourceException e)
            {
                Repair(true, e);
            }
#if !DEBUG
            catch (UnauthorizedAccessException)
            {
                Restart = true;
            }
            catch (TypeInitializationException e)
            {
                Repair(true, e);
            }
            catch (Exception e)
            {
                if (e is BadImageFormatException && handleBadImageFormat(e as BadImageFormatException))
                {
                    return;
                }

                new ErrorDialog(e, true).ShowDialog();
            }
#endif
            BanchoClient.Exit();
        }