/// <summary> /// Reports an <see cref="Exception"/> to the log file and/or user, exiting the game in the process. /// </summary> /// <param name="error">The <see cref="Exception"/> to report.</param> //[CallOnThread("Render")] //[CallOnThread("Updater")] //[CallOnThread("Loader")] //[CallOnThread("Sound")] public void ProcessReportError(Exception error) { // Turn off the watchdog since we're going down. WatchdogProcess.Stop(); // Log the error first in case we're burning. Trace.WriteLine(new FatalException(error)); // Stop the world! Exit(); // Show the user that it's all gone horribly wrong. if (Settings.ShowErrorDialogs) { string errorSummary = error.GetType().FullName + ": " + error.Message; string logFile = Path.Combine(Settings.LoggingPath, Settings.LoggingFilename); DialogResult openTracker = MessageBox.Show($"A fatal error has occured and {RuntimeInfo.ProductName} cannot continue.\n\n" + $" {errorSummary}\n\n" + $"This error may be due to bad data or a bug. You can help improve {RuntimeInfo.ProductName} by reporting this error in our bug tracker at https://github.com/perpetualKid/ORTS-MG/issues and attaching the log file {logFile}.\n\n" + ">>> Click OK to report this error on the GitHub bug tracker <<<", $"{RuntimeInfo.ProductName} {VersionInfo.Version}", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (openTracker == DialogResult.OK) { Process.Start(new ProcessStartInfo("https://github.com/perpetualKid/ORTS-MG/issues") { UseShellExecute = true }); } } }
protected override void EndRun() { base.EndRun(); WatchdogProcess.Stop(); RenderProcess.Stop(); UpdaterProcess.Stop(); LoaderProcess.Stop(); SoundProcess.Stop(); // WebServerProcess.Stop(); Again WebServerProcess.Stop(); }
protected override void BeginRun() { // At this point, GraphicsDevice is initialized and set up. WebServerProcess.Start(); SoundProcess.Start(); LoaderProcess.Start(); UpdaterProcess.Start(); RenderProcess.Start(); #if !DEBUG WatchdogProcess.Start(); #endif base.BeginRun(); }
/// <summary> /// Initializes a new instance of the <see cref="Game"/> based on the specified <see cref="UserSettings"/>. /// </summary> /// <param name="settings">The <see cref="UserSettings"/> for the game to use.</param> public Game(UserSettings settings) { Settings = settings; ContentPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), "Content"); Exiting += new System.EventHandler <System.EventArgs>(Game_Exiting); WatchdogProcess = new WatchdogProcess(this); RenderProcess = new RenderProcess(this); UpdaterProcess = new UpdaterProcess(this); LoaderProcess = new LoaderProcess(this); SoundProcess = new SoundProcess(this); WebServerProcess = new WebServerProcess(this); States = new Stack <GameState>(); }
/// <summary> /// Reports an <see cref="Exception"/> to the log file and/or user, exiting the game in the process. /// </summary> /// <param name="error">The <see cref="Exception"/> to report.</param> //[CallOnThread("Render")] //[CallOnThread("Updater")] //[CallOnThread("Loader")] //[CallOnThread("Sound")] public void ProcessReportError(Exception error) { // Turn off the watchdog since we're going down. WatchdogProcess.Stop(); // Log the error first in case we're burning. Trace.WriteLine(new FatalException(error)); // Stop the world! Exit(); // Show the user that it's all gone horribly wrong. if (Settings.ShowErrorDialogs) { System.Windows.Forms.MessageBox.Show(error.ToString(), Application.ProductName + " " + VersionInfo.VersionOrBuild); } }