コード例 #1
0
ファイル: EventLogger.cs プロジェクト: tchia04/MCDSaveEdit
        public static void logError(string message)
        {
            Debug.WriteLine($"[ERROR] {message}");
#if !DEBUG
            GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, message);
#endif
        }
コード例 #2
0
 public static void LogEvent(string InMessage, EGAErrorSeverity InLogLevel)
 {
     if (mainWindow != null)
     {
         GameAnalytics.AddErrorEvent(InLogLevel, InMessage);
         mainWindow.AddLogEntry($"UE4 Binary Builder Analytics (Log): {InMessage}");
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: yaelatletl/Barotrauma
        static void CrashDump(GameMain game, string filePath, Exception exception)
        {
            StreamWriter sw = new StreamWriter(filePath);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Barotrauma Dedicated Server crash report (generated on " + DateTime.Now + ")");
            sb.AppendLine("\n");
            sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
            sb.AppendLine("\n");
            sb.AppendLine("Game version " + GameMain.Version);
            sb.AppendLine("Selected content packages: " + (!GameMain.SelectedPackages.Any() ? "None" : string.Join(", ", GameMain.SelectedPackages.Select(c => c.Name))));
            sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
            sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Name + " (" + Submarine.MainSub.MD5Hash + ")"));
            sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));

            if (GameMain.Server != null)
            {
                sb.AppendLine("Server (" + (GameMain.Server.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }

            sb.AppendLine("\n");
            sb.AppendLine("System info:");
            sb.AppendLine("    Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));
            sb.AppendLine("\n");
            sb.AppendLine("Exception: " + exception.Message);
            sb.AppendLine("Target site: " + exception.TargetSite.ToString());
            sb.AppendLine("Stack trace: ");
            sb.AppendLine(exception.StackTrace);
            sb.AppendLine("\n");

            sb.AppendLine("Last debug messages:");
            for (int i = DebugConsole.Messages.Count - 1; i > 0 && i > DebugConsole.Messages.Count - 15; i--)
            {
                sb.AppendLine("   " + DebugConsole.Messages[i].Time + " - " + DebugConsole.Messages[i].Text);
            }

            string crashReport = sb.ToString();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(crashReport);

            sw.WriteLine(sb.ToString());
            sw.Close();

            if (GameSettings.SendUserStatistics)
            {
                GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, crashReport);
                GameAnalytics.OnStop();
                Console.Write("A crash report (\"crashreport.log\") was saved in the root folder of the game and sent to the developers.");
            }
            else
            {
                Console.Write("A crash report(\"crashreport.log\") was saved in the root folder of the game. The error was not sent to the developers because user statistics have been disabled, but" +
                              " if you'd like to help fix this bug, you may post it on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/");
            }
            SteamManager.ShutDown();
        }
コード例 #4
0
 public void ReportSessionStart(Dictionary <string, object> sessionData)
 {
     GameAnalytics.AddProgressionEvent(EGAProgressionStatus.Start, "Game");
     foreach (KeyValuePair <string, object> pair in sessionData)
     {
         if (pair.Value != null)
         {
             GameAnalytics.AddErrorEvent(EGAErrorSeverity.Info, $"{pair.Key}: {pair.Value}");
         }
     }
 }
コード例 #5
0
 public async Task Process(GaAddErrorEvent args)
 {
     try
     {
         GameAnalytics.AddErrorEvent(args.Severity, args.Message);
     }
     catch (Exception ex)
     {
         Trace.TraceError("Error adding GA error event {0} : {1}", args?.Message, ex);
     }
 }
コード例 #6
0
        /// <summary>
        /// Adds an error event to GameAnalytics if an event with the same identifier has not been added yet.
        /// </summary>
        public static void AddErrorEventOnce(string identifier, EGAErrorSeverity errorSeverity, string message)
        {
            if (!GameSettings.SendUserStatistics)
            {
                return;
            }
            if (sentEventIdentifiers.Contains(identifier))
            {
                return;
            }

            GameAnalytics.AddErrorEvent(errorSeverity, message);
            sentEventIdentifiers.Add(identifier);
        }
コード例 #7
0
        /// <summary>
        /// Adds an error event to GameAnalytics if an event with the same identifier has not been added yet.
        /// </summary>
        public static void AddErrorEventOnce(string identifier, EGAErrorSeverity errorSeverity, string message)
        {
            if (!GameSettings.SendUserStatistics)
            {
                return;
            }
            if (sentEventIdentifiers.Contains(identifier))
            {
                return;
            }

            if (GameMain.SelectedPackages != null)
            {
                if (GameMain.VanillaContent == null || GameMain.SelectedPackages.Any(p => p.HasMultiplayerIncompatibleContent && p != GameMain.VanillaContent))
                {
                    message = "[MODDED] " + message;
                }
            }

            GameAnalytics.AddErrorEvent(errorSeverity, message);
            sentEventIdentifiers.Add(identifier);
        }
コード例 #8
0
        static void CrashDump(GameMain game, string filePath, Exception exception)
        {
            int    existingFiles    = 0;
            string originalFilePath = filePath;

            while (File.Exists(filePath))
            {
                existingFiles++;
                filePath = Path.GetFileNameWithoutExtension(originalFilePath) + " (" + (existingFiles + 1) + ")" + Path.GetExtension(originalFilePath);
            }

            DebugConsole.DequeueMessages();

            string  exePath = System.Reflection.Assembly.GetEntryAssembly().Location;
            var     md5     = System.Security.Cryptography.MD5.Create();
            Md5Hash exeHash = null;

            try
            {
                using (var stream = File.OpenRead(exePath))
                {
                    exeHash = new Md5Hash(stream);
                }
            }
            catch
            {
                //gotta catch them all, we don't want to throw an exception while writing a crash report
            }

            StreamWriter sw = new StreamWriter(filePath);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Barotrauma Client crash report (generated on " + DateTime.Now + ")");
            sb.AppendLine("\n");
            sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
            sb.AppendLine("\n");
            if (exeHash?.Hash != null)
            {
                sb.AppendLine(exeHash.Hash);
            }
            sb.AppendLine("\n");
#if DEBUG
            sb.AppendLine("Game version " + GameMain.Version + " (debug build)");
#else
            sb.AppendLine("Game version " + GameMain.Version);
#endif
            if (GameMain.Config != null)
            {
                sb.AppendLine("Graphics mode: " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight + " (" + GameMain.Config.WindowMode.ToString() + ")");
            }
            if (GameMain.SelectedPackages != null)
            {
                sb.AppendLine("Selected content packages: " + (!GameMain.SelectedPackages.Any() ? "None" : string.Join(", ", GameMain.SelectedPackages.Select(c => c.Name))));
            }
            sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
            sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Name + " (" + Submarine.MainSub.MD5Hash + ")"));
            sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));
            if (SteamManager.IsInitialized)
            {
                sb.AppendLine("SteamManager initialized");
            }

            if (GameMain.Client != null)
            {
                sb.AppendLine("Client (" + (GameMain.Client.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }

            sb.AppendLine("\n");
            sb.AppendLine("System info:");
            sb.AppendLine("    Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));

            if (game == null)
            {
                sb.AppendLine("    Game not initialized");
            }
            else
            {
                if (game.GraphicsDevice == null)
                {
                    sb.AppendLine("    Graphics device not set");
                }
                else
                {
                    if (game.GraphicsDevice.Adapter == null)
                    {
                        sb.AppendLine("    Graphics adapter not set");
                    }
                    else
                    {
                        sb.AppendLine("    GPU name: " + game.GraphicsDevice.Adapter.Description);
                        sb.AppendLine("    Display mode: " + game.GraphicsDevice.Adapter.CurrentDisplayMode);
                    }

                    sb.AppendLine("    GPU status: " + game.GraphicsDevice.GraphicsDeviceStatus);
                }
            }

            sb.AppendLine("\n");
            sb.AppendLine("Exception: " + exception.Message);
            if (exception.TargetSite != null)
            {
                sb.AppendLine("Target site: " + exception.TargetSite.ToString());
            }
            sb.AppendLine("Stack trace: ");
            sb.AppendLine(exception.StackTrace);
            sb.AppendLine("\n");

            sb.AppendLine("Last debug messages:");
            for (int i = DebugConsole.Messages.Count - 1; i >= 0; i--)
            {
                sb.AppendLine("[" + DebugConsole.Messages[i].Time + "] " + DebugConsole.Messages[i].Text);
            }

            string crashReport = sb.ToString();

            sw.WriteLine(crashReport);
            sw.Close();

            if (GameSettings.SaveDebugConsoleLogs)
            {
                DebugConsole.SaveLogs();
            }

            if (GameSettings.SendUserStatistics)
            {
                CrashMessageBox("A crash report (\"" + filePath + "\") was saved in the root folder of the game and sent to the developers.");
                GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, crashReport);
                GameAnalytics.OnQuit();
            }
            else
            {
                CrashMessageBox("A crash report (\"" + filePath + "\") was saved in the root folder of the game. The error was not sent to the developers because user statistics have been disabled, but" +
                                " if you'd like to help fix this bug, you may post it on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/");
            }
        }
コード例 #9
0
        static void CrashDump(GameMain game, string filePath, Exception exception)
        {
            StreamWriter sw = new StreamWriter(filePath);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Barotrauma Dedicated Server crash report (generated on " + DateTime.Now + ")");
            sb.AppendLine("\n");
            sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
            sb.AppendLine("\n");
            sb.AppendLine("Game version " + GameMain.Version + " NILMOD SERVER MODIFICATION");
            sb.AppendLine("Nilmod version stamp: " + NilMod.NilModVersionDate);
            //sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
            sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
            sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Name + " (" + Submarine.MainSub.MD5Hash + ")"));
            sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));

            if (GameMain.GameSession != null)
            {
                if (GameMain.GameSession.Mission != null)
                {
                    sb.AppendLine("Mission: " + GameMain.GameSession.Mission.Name);
                }
                if (GameMain.GameSession.GameMode != null)
                {
                    sb.AppendLine("Gamemode: " + GameMain.GameSession.GameMode.Name);
                }
            }

            if (Character.CharacterList != null && Character.CharacterList.Count > 0)
            {
                sb.AppendLine("\n");
                if (Character.CharacterList.FindAll(c => c.Removed).Count > 0)
                {
                    sb.AppendLine("Removed character references detected, " + Character.CharacterList.Count + " Characters in list, " + Character.CharacterList.FindAll(c => c.Removed).Count + " Removed.");
                }

                int foundnullanimcontroller = 0;
                int foundnulllimbs          = 0;
                int foundzerolengthlimbs    = 0;
                for (int i = Character.CharacterList.Count - 1; i >= 0; i--)
                {
                    if (Character.CharacterList[i].AnimController == null)
                    {
                        foundnullanimcontroller += 1;
                    }
                    else
                    {
                        if (Character.CharacterList[i].AnimController.Limbs == null)
                        {
                            foundnulllimbs += 1;
                        }
                        else if (Character.CharacterList[i].AnimController.Limbs.Length < 1)
                        {
                            foundzerolengthlimbs += 1;
                        }
                    }
                }
                if (foundnullanimcontroller > 0)
                {
                    sb.AppendLine(foundnullanimcontroller + " Characters with null AnimControllers found.");
                }
                if (foundnulllimbs > 0)
                {
                    sb.AppendLine(foundnulllimbs + " Characters with null limbs[] reference found.");
                }
                if (foundzerolengthlimbs > 0)
                {
                    sb.AppendLine(foundzerolengthlimbs + " characters with 0 limbs found.");
                }
            }

            if (GameMain.Server != null)
            {
                sb.AppendLine("Server (" + (GameMain.Server.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }

            sb.AppendLine("\n");
            sb.AppendLine("System info:");
            sb.AppendLine("    Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));
            sb.AppendLine("\n");
            sb.AppendLine("This was running NilMod Code!");
            sb.AppendLine("\n");
            sb.AppendLine("Exception: " + exception.Message);
            sb.AppendLine("Target site: " + exception.TargetSite.ToString());
            sb.AppendLine("Stack trace: ");
            sb.AppendLine(exception.StackTrace);
            sb.AppendLine("\n");

            sb.AppendLine("Last debug messages:");
            for (int i = DebugConsole.Messages.Count - 1; i > 0; i--)
            {
                sb.AppendLine("   " + DebugConsole.Messages[i].Time + " - " + DebugConsole.Messages[i].Text);
            }

            string crashReport = sb.ToString();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(sb.ToString());

            sw.WriteLine(sb.ToString());
            sw.Close();

            if (GameSettings.SendUserStatistics)
            {
                GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, crashReport);
                GameAnalytics.OnStop();
                Console.Write("A crash report (\"crashreport.log\") was saved in the root folder of the game and sent to the developers.");
            }
            else
            {
                Console.Write("A crash report(\"crashreport.log\") was saved in the root folder of the game. The error was not sent to the developers because user statistics have been disabled, but" +
                              "If you'd like to help fix this bug, please post the report on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/" + Environment.NewLine +
                              "Alternatively, If you believe this to be a mod bug, please post the report on the forum topic or the mods GitHub issue tracker: https://github.com/NilanthAnimosus/Barotrauma---Nilanths-Edits/issues");
            }

            if (GameMain.NilMod != null)
            {
                if (GameMain.NilMod.CrashRestart && GameMain.NilMod.SuccesfulStart)
                {
                    CrashRestart(null, exception);
                }
            }
        }
コード例 #10
0
        static void CrashDump(string filePath, Exception exception)
        {
            try
            {
                GameMain.Server?.ServerSettings?.SaveSettings();
                GameMain.Server?.ServerSettings?.BanList.Save();
                if (GameMain.Server?.ServerSettings?.KarmaPreset == "custom")
                {
                    GameMain.Server?.KarmaManager?.SaveCustomPreset();
                    GameMain.Server?.KarmaManager?.Save();
                }
            }
            catch (Exception e)
            {
                //couldn't save, whatever
            }

            int    existingFiles    = 0;
            string originalFilePath = filePath;

            while (File.Exists(filePath))
            {
                existingFiles++;
                filePath = Path.GetFileNameWithoutExtension(originalFilePath) + " (" + (existingFiles + 1) + ")" + Path.GetExtension(originalFilePath);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Barotrauma Dedicated Server crash report (generated on " + DateTime.Now + ")");
            sb.AppendLine("\n");
            sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
            sb.AppendLine("\n");
            sb.AppendLine("Game version " + GameMain.Version + " (" + AssemblyInfo.BuildString + ", branch " + AssemblyInfo.GitBranch + ", revision " + AssemblyInfo.GitRevision + ")");
            if (GameMain.Config != null)
            {
                sb.AppendLine("Language: " + (GameMain.Config.Language ?? "none"));
            }
            if (GameMain.Config.AllEnabledPackages != null)
            {
                sb.AppendLine("Selected content packages: " + (!GameMain.Config.AllEnabledPackages.Any() ? "None" : string.Join(", ", GameMain.Config.AllEnabledPackages.Select(c => c.Name))));
            }
            sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
            sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Info.Name + " (" + Submarine.MainSub.Info.MD5Hash + ")"));
            sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));

            if (GameMain.Server != null)
            {
                sb.AppendLine("Server (" + (GameMain.Server.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }

            sb.AppendLine("\n");
            sb.AppendLine("System info:");
            sb.AppendLine("    Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));
            sb.AppendLine("\n");
            sb.AppendLine("Exception: " + exception.Message + " (" + exception.GetType().ToString() + ")");
            sb.AppendLine("Target site: " + exception.TargetSite.ToString());
            if (exception.StackTrace != null)
            {
                sb.AppendLine("Stack trace: ");
                sb.AppendLine(exception.StackTrace.CleanupStackTrace());
                sb.AppendLine("\n");
            }

            if (exception.InnerException != null)
            {
                sb.AppendLine("InnerException: " + exception.InnerException.Message);
                if (exception.InnerException.TargetSite != null)
                {
                    sb.AppendLine("Target site: " + exception.InnerException.TargetSite.ToString());
                }
                if (exception.InnerException.StackTrace != null)
                {
                    sb.AppendLine("Stack trace: ");
                    sb.AppendLine(exception.InnerException.StackTrace.CleanupStackTrace());
                }
            }

            sb.AppendLine("Last debug messages:");
            DebugConsole.Clear();
            for (int i = DebugConsole.Messages.Count - 1; i > 0 && i > DebugConsole.Messages.Count - 15; i--)
            {
                sb.AppendLine("   " + DebugConsole.Messages[i].Time + " - " + DebugConsole.Messages[i].Text);
            }

            string crashReport = sb.ToString();

            Console.ForegroundColor = ConsoleColor.Red;
            Console.Write(crashReport);

            File.WriteAllText(filePath, sb.ToString());

            if (GameSettings.SendUserStatistics)
            {
                GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, crashReport);
                GameAnalytics.OnQuit();
                Console.Write("A crash report (\"servercrashreport.log\") was saved in the root folder of the game and sent to the developers.");
            }
            else
            {
                Console.Write("A crash report(\"servercrashreport.log\") was saved in the root folder of the game. The error was not sent to the developers because user statistics have been disabled, but" +
                              " if you'd like to help fix this bug, you may post it on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/");
            }
            SteamManager.ShutDown();
        }
コード例 #11
0
        private static void Main(string[] args)
        {
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;

            if (!Debugger.IsAttached)
            {
                Trace.Listeners.Add(new ConsoleTraceListener());
            }

            var logStringBuilder = new StringBuilder();
            var threadSafeWriter = TextWriter.Synchronized(new StringWriter(logStringBuilder));

            Trace.Listeners.Add(new TextWriterTraceListener(threadSafeWriter));

            try
            {
                GameAnalytics.Initialize(GlobalConst.GameAnalyticsGameKey, GlobalConst.GameAnalyticsToken);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error starting GameAnalytics: {0}", ex);
            }

            string chobbyTag, engineOverride;
            ulong  connectLobbyID;

            ParseCommandLine(args, out connectLobbyID, out chobbyTag, out engineOverride);

            var startupPath = Path.GetDirectoryName(Path.GetFullPath(Application.ExecutablePath));

            if (!SpringPaths.IsDirectoryWritable(startupPath))
            {
                MessageBox.Show("Please move this program to a writable folder",
                                "Cannot write to startup folder",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, "Wrapper cannot start, folder not writable");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex);
                }
                Environment.Exit(0);
                return;
            }

            Application.EnableVisualStyles();

            try
            {
                var chobbyla = new Chobbyla(startupPath, chobbyTag, engineOverride);
                RunWrapper(chobbyla, connectLobbyID, threadSafeWriter, logStringBuilder);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Error starting chobby: {0}", ex);
                MessageBox.Show(ex.ToString(), "Error starting Chobby", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, "Wrapper crash: " + ex);
                }
                catch (Exception ex2)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex2);
                }
            }

            try
            {
                GameAnalytics.OnStop();
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Error ending GA session: {0}", ex);
            }

            threadSafeWriter.Flush();
            try
            {
                File.WriteAllText(Path.Combine(startupPath, "infolog_full.txt"), logStringBuilder.ToString());
            }
            catch (Exception ex)
            {
                Trace.TraceWarning("Error writing full infolog: {0}", ex);
            }
            Environment.Exit(0);
        }
コード例 #12
0
        private static void RunWrapper(Chobbyla chobbyla, ulong connectLobbyID, TextWriter logWriter, StringBuilder logSb)
        {
            if (!chobbyla.IsSteamFolder) // not steam, show gui
            {
                var cf = new ChobbylaForm(chobbyla)
                {
                    StartPosition = FormStartPosition.CenterScreen
                };
                if (cf.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            else if (!chobbyla.Prepare().Result)
            {
                return;                                  // otherwise just do simple prepare, no gui
            }
            var springRunOk = chobbyla.Run(connectLobbyID, logWriter);

            Trace.TraceInformation("Spring exited");
            if (!springRunOk)
            {
                Trace.TraceWarning("Spring crash detected");
            }

            logWriter.Flush();
            var logStr = logSb.ToString();

            var syncError = CrashReportHelper.IsDesyncMessage(logStr);

            if (syncError)
            {
                Trace.TraceWarning("Sync error detected");
            }

            var openGlFail = logStr.Contains("No OpenGL drivers installed.") ||
                             logStr.Contains("Please go to your GPU vendor's website and download their drivers.") ||
                             logStr.Contains("minimum required OpenGL version not supported, aborting") ||
                             logStr.Contains("Update your graphic-card driver!");


            if (openGlFail)
            {
                Trace.TraceWarning("Outdated OpenGL detected");
                MessageBox.Show("You have outdated graphics card drivers!\r\nPlease try finding ones for your graphics card and updating them.", "Outdate graphics card driver detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if ((!springRunOk && !openGlFail) || syncError) // crash has occured
            {
                if (
                    MessageBox.Show("We would like to send crash/desync data to Zero-K repository, it can contain chat. Do you agree?",
                                    "Automated crash report",
                                    MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    var ret = CrashReportHelper.ReportCrash(logSb.ToString(), syncError, chobbyla.engine);
                    if (ret != null)
                    {
                        try
                        {
                            Process.Start(ret.HtmlUrl.ToString());
                        }
                        catch { }
                    }
                }

                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, "Spring crash");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex);
                }
            }
        }
コード例 #13
0
        public async Task <bool> Prepare()
        {
            try
            {
                PackageDownloader.Version ver = null;
                internalName = null;

                if (!isDev)
                {
                    if (!Debugger.IsAttached && !IsSteamFolder)
                    {
                        Status = "Checking for self-upgrade";
                        var selfUpdater = new SelfUpdater("Zero-K");
                        selfUpdater.ProgramUpdated += delegate
                        {
                            Process.Start(Application.ExecutablePath, string.Join(" ", Environment.GetCommandLineArgs().Skip(1)));
                            Environment.Exit(0);
                        };
                        var task = new Task <bool>(() => selfUpdater.CheckForUpdate());
                        task.Start();
                        await task;
                    }

                    if (!IsSteamFolder)
                    {
                        downloader.RapidHandling = RapidHandling.SdzNameHash;

                        if (!await downloader.DownloadFile("Checking for chobby update", DownloadType.RAPID, chobbyTag, Progress, 2))
                        {
                            return(false);
                        }
                        if (!await downloader.DownloadFile("Checking for game update", DownloadType.RAPID, GlobalConst.DefaultZkTag, Progress, 2))
                        {
                            return(false);
                        }

                        downloader.RapidHandling = RapidHandling.DefaultSdp;

                        ver          = downloader.PackageDownloader.GetByTag(chobbyTag);
                        internalName = ver.InternalName;
                    }
                    else
                    {
                        internalName = GetSteamChobby();
                        ver          = downloader.PackageDownloader.GetByInternalName(internalName) ?? downloader.PackageDownloader.GetByTag(chobbyTag);
                    }

                    if (ver == null)
                    {
                        Status = "Rapid package appears to be corrupted, please clear the folder";
                        return(false);
                    }
                }
                else
                {
                    internalName = "Chobby $VERSION";
                }


                engine = engine ?? GetSteamEngine() ?? QueryDefaultEngine() ?? GlobalConst.DefaultEngineOverride;

                try
                {
                    GameAnalytics.ConfigureGameEngineVersion(internalName);
                    GameAnalytics.ConfigureSdkGameEngineVersion(engine);
                }
                catch (Exception ex)
                {
                    Trace.TraceWarning("Game analytics failed to configure version: {0}", ex);
                }


                if (!IsSteamFolder)
                {
                    if (!await downloader.DownloadFile("Downloading engine", DownloadType.ENGINE, engine, Progress, 2))
                    {
                        return(false);
                    }

                    if (!await downloader.UpdateMissions(Progress))
                    {
                        Trace.TraceWarning("Mission update has failed");
                        Status = "Error updating missions";
                    }
                }
                else
                {
                    ClearSdp();
                }



                downloader.UpdatePublicCommunityInfo(Progress);

                if (!isDev)
                {
                    Status = "Reseting configs and deploying AIs";
                    ConfigVersions.DeployAndResetConfigs(paths, ver);
                }


                return(true);
            }
            catch (Exception ex)
            {
                Trace.TraceError("Unexpected error: {0}", ex);
                GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, $"Unexpected error {Status}: {ex}");
                Status = "Unexpected error preparing chobby launch: " + ex.Message;
                return(false);
            }
        }
コード例 #14
0
        private static void RunWrapper(Chobbyla chobbyla, ulong connectLobbyID, TextWriter logWriter, StringBuilder logSb)
        {
            if (!chobbyla.IsSteamFolder) // not steam, show gui
            {
                var cf = new ChobbylaForm(chobbyla)
                {
                    StartPosition = FormStartPosition.CenterScreen
                };
                if (cf.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }
            else if (!chobbyla.Prepare().Result)
            {
                return;                                  // otherwise just do simple prepare, no gui
            }
            var springRunOk = chobbyla.Run(connectLobbyID, logWriter);

            Trace.TraceInformation("Spring exited");
            if (!springRunOk)
            {
                Trace.TraceWarning("Spring crash detected");
            }

            logWriter.Flush();
            var logStr = logSb.ToString();

            var syncError = CrashReportHelper.IsDesyncMessage(logStr);

            if (syncError)
            {
                Trace.TraceWarning("Sync error detected");
            }

            var openGlFail = logStr.Contains("No OpenGL drivers installed.") ||
                             logStr.Contains("This stack trace indicates a problem with your graphic card driver") ||
                             logStr.Contains("Please go to your GPU vendor's website and download their drivers.") ||
                             logStr.Contains("minimum required OpenGL version not supported, aborting") ||
                             logStr.Contains("Update your graphic-card driver!");


            if (openGlFail)
            {
                Trace.TraceWarning("Outdated OpenGL detected");

                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    if (MessageBox.Show("You have outdated graphics card drivers!\r\nPlease try finding ones for your graphics card and updating them. \r\n\r\nWould you like to see our Linux graphics driver guide?", "Outdated graphics card driver detected", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        Process.Start("http://zero-k.info/mediawiki/index.php?title=Optimized_Graphics_Linux");
                    }
                }
                else
                {
                    MessageBox.Show("You have outdated graphics card drivers!\r\nPlease try finding ones for your graphics card and updating them.", "Outdated graphics card driver detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            var luaErr = logStr.Contains("LUA_ERRRUN");



            if ((!springRunOk && !openGlFail) || syncError || luaErr || !string.IsNullOrEmpty(chobbyla.BugReportTitle)) // crash has occured
            {
                if (
                    MessageBox.Show("We would like to send crash/desync data to Zero-K repository, it can contain chat. Do you agree?",
                                    "Automated crash report",
                                    MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    var crashType = syncError ? CrashType.Desync : luaErr ? CrashType.LuaError : CrashType.Crash;
                    if (!string.IsNullOrEmpty(chobbyla.BugReportTitle))
                    {
                        crashType = CrashType.UserReport;
                    }

                    var ret = CrashReportHelper.ReportCrash(logSb.ToString(), crashType, chobbyla.engine, chobbyla.BugReportTitle, chobbyla.BugReportDescription);
                    if (ret != null)
                    {
                        try
                        {
                            Process.Start(ret.HtmlUrl.ToString());
                        }
                        catch { }
                    }
                }

                try
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, "Spring crash");
                }
                catch (Exception ex)
                {
                    Trace.TraceError("Error adding GA error event: {0}", ex);
                }
            }
        }
コード例 #15
0
        static void CrashDump(GameMain game, string filePath, Exception exception)
        {
            int    existingFiles    = 0;
            string originalFilePath = filePath;

            while (File.Exists(filePath))
            {
                existingFiles++;
                filePath = Path.GetFileNameWithoutExtension(originalFilePath) + " (" + (existingFiles + 1) + ")" + Path.GetExtension(originalFilePath);
            }

            DebugConsole.DequeueMessages();

            Md5Hash exeHash = null;

            try
            {
                string exePath  = System.Reflection.Assembly.GetEntryAssembly().Location;
                var    md5      = System.Security.Cryptography.MD5.Create();
                byte[] exeBytes = File.ReadAllBytes(exePath);
                exeHash = new Md5Hash(exeBytes);
            }
            catch
            {
                //do nothing, generate the rest of the crash report
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Barotrauma Client crash report (generated on " + DateTime.Now + ")");
            sb.AppendLine("\n");
            sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
            sb.AppendLine("\n");

            try
            {
                if (exception is GameMain.LoadingException)
                {
                    //exception occurred in loading screen:
                    //assume content packages are the culprit and reset them
                    XDocument doc     = XMLExtensions.TryLoadXml(GameSettings.PlayerSavePath);
                    XDocument baseDoc = XMLExtensions.TryLoadXml(GameSettings.SavePath);
                    if (doc != null && baseDoc != null)
                    {
                        XElement newElement = new XElement(doc.Root.Name);
                        newElement.Add(doc.Root.Attributes());
                        newElement.Add(doc.Root.Elements().Where(e => !e.Name.LocalName.Equals("contentpackage", StringComparison.InvariantCultureIgnoreCase)));
                        newElement.Add(baseDoc.Root.Elements().Where(e => e.Name.LocalName.Equals("contentpackage", StringComparison.InvariantCultureIgnoreCase)));
                        XDocument newDoc = new XDocument(newElement);
                        newDoc.Save(GameSettings.PlayerSavePath);
                        sb.AppendLine("To prevent further startup errors, installed mods will be disabled the next time you launch the game.");
                        sb.AppendLine("\n");
                    }
                }
            }
            catch
            {
                //welp i guess we couldn't reset the config!
            }

            if (exeHash?.Hash != null)
            {
                sb.AppendLine(exeHash.Hash);
            }
            sb.AppendLine("\n");
            sb.AppendLine("Game version " + GameMain.Version +
                          " (" + AssemblyInfo.BuildString + ", branch " + AssemblyInfo.GitBranch + ", revision " + AssemblyInfo.GitRevision + ")");
            if (GameMain.Config != null)
            {
                sb.AppendLine("Graphics mode: " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight + " (" + GameMain.Config.WindowMode.ToString() + ")");
                sb.AppendLine("VSync " + (GameMain.Config.VSyncEnabled ? "ON" : "OFF"));
                sb.AppendLine("Language: " + (GameMain.Config.Language ?? "none"));
            }
            if (GameMain.Config.AllEnabledPackages != null)
            {
                sb.AppendLine("Selected content packages: " + (!GameMain.Config.AllEnabledPackages.Any() ? "None" : string.Join(", ", GameMain.Config.AllEnabledPackages.Select(c => c.Name))));
            }
            sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
            sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Info.Name + " (" + Submarine.MainSub.Info.MD5Hash + ")"));
            sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));
            if (SteamManager.IsInitialized)
            {
                sb.AppendLine("SteamManager initialized");
            }

            if (GameMain.Client != null)
            {
                sb.AppendLine("Client (" + (GameMain.Client.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }

            sb.AppendLine("\n");
            sb.AppendLine("System info:");
            sb.AppendLine("    Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));

            if (game == null)
            {
                sb.AppendLine("    Game not initialized");
            }
            else
            {
                if (game.GraphicsDevice == null)
                {
                    sb.AppendLine("    Graphics device not set");
                }
                else
                {
                    if (game.GraphicsDevice.Adapter == null)
                    {
                        sb.AppendLine("    Graphics adapter not set");
                    }
                    else
                    {
                        sb.AppendLine("    GPU name: " + game.GraphicsDevice.Adapter.Description);
                        sb.AppendLine("    Display mode: " + game.GraphicsDevice.Adapter.CurrentDisplayMode);
                    }

                    sb.AppendLine("    GPU status: " + game.GraphicsDevice.GraphicsDeviceStatus);
                }
            }

            sb.AppendLine("\n");
            sb.AppendLine("Exception: " + exception.Message + " (" + exception.GetType().ToString() + ")");
#if WINDOWS
            if (exception is SharpDXException sharpDxException && ((uint)sharpDxException.HResult) == 0x887A0005)
            {
                var dxDevice = (SharpDX.Direct3D11.Device)game.GraphicsDevice.Handle;
                sb.AppendLine("Device removed reason: " + dxDevice.DeviceRemovedReason.ToString());
            }
#endif
            if (exception.TargetSite != null)
            {
                sb.AppendLine("Target site: " + exception.TargetSite.ToString());
            }

            sb.AppendLine("Stack trace: ");
            sb.AppendLine(exception.StackTrace.CleanupStackTrace());
            sb.AppendLine("\n");

            if (exception.InnerException != null)
            {
                sb.AppendLine("InnerException: " + exception.InnerException.Message);
                if (exception.InnerException.TargetSite != null)
                {
                    sb.AppendLine("Target site: " + exception.InnerException.TargetSite.ToString());
                }
                sb.AppendLine("Stack trace: ");
                sb.AppendLine(exception.InnerException.StackTrace.CleanupStackTrace());
            }

            sb.AppendLine("Last debug messages:");
            for (int i = DebugConsole.Messages.Count - 1; i >= 0; i--)
            {
                sb.AppendLine("[" + DebugConsole.Messages[i].Time + "] " + DebugConsole.Messages[i].Text);
            }

            string crashReport = sb.ToString();

            File.WriteAllText(filePath, crashReport);

            if (GameSettings.SaveDebugConsoleLogs)
            {
                DebugConsole.SaveLogs();
            }

            if (GameSettings.SendUserStatistics)
            {
                CrashMessageBox("A crash report (\"" + filePath + "\") was saved in the root folder of the game and sent to the developers.", filePath);
                GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, crashReport);
                GameAnalytics.OnQuit();
            }
            else
            {
                CrashMessageBox("A crash report (\"" + filePath + "\") was saved in the root folder of the game. The error was not sent to the developers because user statistics have been disabled, but" +
                                " if you'd like to help fix this bug, you may post it on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/", filePath);
            }
        }
コード例 #16
0
 private static void addErrorEvent(int severity, string message, string fields)
 {
     GameAnalytics.AddErrorEvent((EGAErrorSeverity)severity, message);
 }
コード例 #17
0
        static void CrashDump(GameMain game, string filePath, Exception exception)
        {
            DebugConsole.DequeueMessages();

            StreamWriter sw = new StreamWriter(filePath);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Barotrauma Client crash report (generated on " + DateTime.Now + ")");
            sb.AppendLine("\n");
            sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
            sb.AppendLine("\n");
#if DEBUG
            sb.AppendLine("Game version " + GameMain.Version + " NILMOD SERVER MODIFICATION" + " (debug build)");
#else
            sb.AppendLine("Game version " + GameMain.Version + " NILMOD SERVER MODIFICATION");
#endif
            sb.AppendLine("Nilmod version stamp: " + NilMod.NilModVersionDate);
            sb.AppendLine("Graphics mode: " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight + " (" + GameMain.Config.WindowMode.ToString() + ")");
            sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
            sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
            sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Name + " (" + Submarine.MainSub.MD5Hash + ")"));
            sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));

            if (GameMain.GameSession != null)
            {
                if (GameMain.GameSession.GameMode != null)
                {
                    sb.AppendLine("Gamemode: " + GameMain.GameSession.GameMode.Name);
                }
                if (GameMain.GameSession.Mission != null)
                {
                    sb.AppendLine("Mission: " + GameMain.GameSession.Mission.Name);
                }
            }

            if (Character.CharacterList != null && Character.CharacterList.Count > 0)
            {
                sb.AppendLine("\n");
                if (Character.CharacterList.FindAll(c => c.Removed).Count > 0)
                {
                    sb.AppendLine("Removed character references detected, " + Character.CharacterList.Count + " Characters in list, " + Character.CharacterList.FindAll(c => c.Removed).Count + " Removed.");
                }

                int foundnullanimcontroller = 0;
                int foundnulllimbs          = 0;
                int foundzerolengthlimbs    = 0;
                for (int i = Character.CharacterList.Count - 1; i >= 0; i--)
                {
                    if (Character.CharacterList[i].AnimController == null)
                    {
                        foundnullanimcontroller += 1;
                    }
                    else
                    {
                        if (Character.CharacterList[i].AnimController.Limbs == null)
                        {
                            foundnulllimbs += 1;
                        }
                        else if (Character.CharacterList[i].AnimController.Limbs.Length < 1)
                        {
                            foundzerolengthlimbs += 1;
                        }
                    }
                }
                if (foundnullanimcontroller > 0)
                {
                    sb.AppendLine(foundnullanimcontroller + " Characters with null AnimControllers found.");
                }
                if (foundnulllimbs > 0)
                {
                    sb.AppendLine(foundnulllimbs + " Characters with null limbs[] reference found.");
                }
                if (foundzerolengthlimbs > 0)
                {
                    sb.AppendLine(foundzerolengthlimbs + " characters with 0 limbs found.");
                }
            }

            if (GameMain.Server != null)
            {
                sb.AppendLine("Server (" + (GameMain.Server.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }
            else if (GameMain.Client != null)
            {
                sb.AppendLine("Client (" + (GameMain.Client.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }

            sb.AppendLine("\n");
            sb.AppendLine("System info:");
            sb.AppendLine("    Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));

            if (game.GraphicsDevice == null)
            {
                sb.AppendLine("    Graphics device not set");
            }
            else
            {
                if (game.GraphicsDevice.Adapter == null)
                {
                    sb.AppendLine("    Graphics adapter not set");
                }
                else
                {
                    sb.AppendLine("    GPU name: " + game.GraphicsDevice.Adapter.Description);
                    sb.AppendLine("    Display mode: " + game.GraphicsDevice.Adapter.CurrentDisplayMode);
                }

                sb.AppendLine("    GPU status: " + game.GraphicsDevice.GraphicsDeviceStatus);
            }

#if LINUX
            if (GameMain.NilMod != null && GameMain.NilMod.CrashRestart)
            {
                sb.AppendLine("\n");
                sb.AppendLine("Attempted restart of process using: " + System.Diagnostics.Process.Start(System.Reflection.Assembly.GetEntryAssembly().CodeBase + "\\Barotrauma NilEdit.exe"));
                sb.AppendLine("\n");
            }
#else
            if (GameMain.NilMod != null && GameMain.NilMod.CrashRestart)
            {
                sb.AppendLine("\n");
                sb.AppendLine("Attempted restart of process using: " + Application.StartupPath + "\\Barotrauma NilEdit.exe");
                sb.AppendLine("\n");
            }
#endif

            sb.AppendLine("\n");
            sb.AppendLine("This was running NilMod Code!");
            sb.AppendLine("\n");
            sb.AppendLine("Exception: " + exception.Message);
            sb.AppendLine("Target site: " + exception.TargetSite.ToString());
            sb.AppendLine("Stack trace: ");
            sb.AppendLine(exception.StackTrace);
            sb.AppendLine("\n");

            sb.AppendLine("Last debug messages:");
            if (game != null)
            {
                if (GameMain.NilMod != null)
                {
                    if (GameMain.NilMod.DebugConsoleTimeStamp)
                    {
                        for (int i = DebugConsole.Messages.Count - 1; i > 0; i--)
                        {
                            sb.AppendLine(DebugConsole.Messages[i].Text);
                        }
                    }
                    else
                    {
                        for (int i = DebugConsole.Messages.Count - 1; i > 0; i--)
                        {
                            sb.AppendLine("[" + DebugConsole.Messages[i].Time + "] " + DebugConsole.Messages[i].Text);
                        }
                    }
                }
                else
                {
                    for (int i = DebugConsole.Messages.Count - 1; i > 0; i--)
                    {
                        sb.AppendLine("[" + DebugConsole.Messages[i].Time + "] " + DebugConsole.Messages[i].Text);
                    }
                }
            }
            else
            {
                for (int i = DebugConsole.Messages.Count - 1; i > 0; i--)
                {
                    sb.AppendLine("[" + DebugConsole.Messages[i].Time + "] " + DebugConsole.Messages[i].Text);
                }
            }

            string crashReport = sb.ToString();

            sw.WriteLine(crashReport);
            sw.Close();

            if (GameMain.NilMod != null)
            {
                if (GameMain.NilMod.CrashRestart && GameMain.NilMod.SuccesfulStart)
                {
                    if (GameSettings.SaveDebugConsoleLogs)
                    {
                        DebugConsole.SaveLogs();
                    }

                    if (GameSettings.SendUserStatistics)
                    {
                        GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, crashReport);
                        GameAnalytics.OnStop();
                    }

                    CrashRestart(null, exception);
                }
                else
                {
                    if (GameSettings.SaveDebugConsoleLogs)
                    {
                        DebugConsole.SaveLogs();
                    }

                    if (GameSettings.SendUserStatistics)
                    {
                        CrashMessageBox("A crash report (\"crashreport.log\") was saved in the root folder of the game and sent to the developers.");
                        GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, crashReport);
                        GameAnalytics.OnStop();
                    }
                    else
                    {
                        CrashMessageBox("A crash report (\"crashreport.log\") was saved in the root folder of the game." + Environment.NewLine +
                                        "If you'd like to help fix this bug, please post the report on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/" + Environment.NewLine +
                                        "Alternatively, If you believe this to be a mod bug, please post the report on the forum topic or the mods GitHub issue tracker: https://github.com/NilanthAnimosus/Barotrauma---Nilanths-Edits/issues");
                    }
                }
            }
            else
            {
                if (GameSettings.SaveDebugConsoleLogs)
                {
                    DebugConsole.SaveLogs();
                }

                CrashMessageBox("A crash report (\"crashreport.log\") was saved in the root folder of the game." + Environment.NewLine +
                                "If you'd like to help fix this bug, please post the report on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/" + Environment.NewLine +
                                "Alternatively, If you believe this to be a mod bug, please post the report on the forum topic or the mods GitHub issue tracker: https://github.com/NilanthAnimosus/Barotrauma---Nilanths-Edits/issues");
            }
        }
コード例 #18
0
        public void ReportEvent(MyAnalyticsProgressionStatus status, Dictionary <string, object> eventData, double timestamp = 0.0)
        {
            object obj2;
            ulong  testValue = GetTestValue();
            string str       = "Test " + testValue;

            switch (status)
            {
            case MyAnalyticsProgressionStatus.GameQuit:
                GameAnalytics.AddProgressionEvent(EGAProgressionStatus.Complete, str, status.ToString());
                return;

            case MyAnalyticsProgressionStatus.GameCrash:
                object obj3;
                if (eventData.TryGetValue("exception", out obj3))
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Critical, obj3.ToString());
                    return;
                }
                return;

            case MyAnalyticsProgressionStatus.WorldStart:
                if (eventData.TryGetValue("world_type", out obj2))
                {
                    GameAnalytics.AddProgressionEvent(EGAProgressionStatus.Start, str, obj2.ToString());
                }
                else
                {
                    GameAnalytics.AddProgressionEvent(EGAProgressionStatus.Start, "Game", "UnknownWorld");
                }
                foreach (KeyValuePair <string, object> pair in eventData)
                {
                    if (pair.Value != null)
                    {
                        GameAnalytics.AddErrorEvent(EGAErrorSeverity.Info, $"{pair.Key}: {pair.Value}");
                    }
                }
                return;

            case MyAnalyticsProgressionStatus.WorldEnd:
                break;

            default:
                if (status == MyAnalyticsProgressionStatus.BugReport)
                {
                    object obj4;
                    if (!eventData.TryGetValue("data", out obj4))
                    {
                        obj4 = "[Null]";
                    }
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Info, obj4.ToString());
                    return;
                }
                else
                {
                    GameAnalytics.AddProgressionEvent(EGAProgressionStatus.Undefined, "Game", status.ToString());
                }
                return;
            }
            if (eventData.TryGetValue("world_type", out obj2))
            {
                GameAnalytics.AddProgressionEvent(EGAProgressionStatus.Complete, str, obj2.ToString());
            }
            else
            {
                GameAnalytics.AddProgressionEvent(EGAProgressionStatus.Complete, "Game", "UnknownWorld");
            }
            foreach (KeyValuePair <string, object> pair2 in eventData)
            {
                if (pair2.Value != null)
                {
                    GameAnalytics.AddErrorEvent(EGAErrorSeverity.Info, $"{pair2.Key}: {pair2.Value}");
                }
            }
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: sylvinite/Barotrauma
        static void CrashDump(GameMain game, string filePath, Exception exception)
        {
            DebugConsole.DequeueMessages();

            StreamWriter sw = new StreamWriter(filePath);

            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Barotrauma Client crash report (generated on " + DateTime.Now + ")");
            sb.AppendLine("\n");
            sb.AppendLine("Barotrauma seems to have crashed. Sorry for the inconvenience! ");
            sb.AppendLine("\n");
#if DEBUG
            sb.AppendLine("Game version " + GameMain.Version + " (debug build)");
#else
            sb.AppendLine("Game version " + GameMain.Version);
#endif
            sb.AppendLine("Graphics mode: " + GameMain.Config.GraphicsWidth + "x" + GameMain.Config.GraphicsHeight + " (" + GameMain.Config.WindowMode.ToString() + ")");
            sb.AppendLine("Selected content package: " + GameMain.SelectedPackage.Name);
            sb.AppendLine("Level seed: " + ((Level.Loaded == null) ? "no level loaded" : Level.Loaded.Seed));
            sb.AppendLine("Loaded submarine: " + ((Submarine.MainSub == null) ? "None" : Submarine.MainSub.Name + " (" + Submarine.MainSub.MD5Hash + ")"));
            sb.AppendLine("Selected screen: " + (Screen.Selected == null ? "None" : Screen.Selected.ToString()));

            if (GameMain.Server != null)
            {
                sb.AppendLine("Server (" + (GameMain.Server.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }
            else if (GameMain.Client != null)
            {
                sb.AppendLine("Client (" + (GameMain.Client.GameStarted ? "Round had started)" : "Round hadn't been started)"));
            }

            sb.AppendLine("\n");
            sb.AppendLine("System info:");
            sb.AppendLine("    Operating system: " + System.Environment.OSVersion + (System.Environment.Is64BitOperatingSystem ? " 64 bit" : " x86"));

            if (game.GraphicsDevice == null)
            {
                sb.AppendLine("    Graphics device not set");
            }
            else
            {
                if (game.GraphicsDevice.Adapter == null)
                {
                    sb.AppendLine("    Graphics adapter not set");
                }
                else
                {
                    sb.AppendLine("    GPU name: " + game.GraphicsDevice.Adapter.Description);
                    sb.AppendLine("    Display mode: " + game.GraphicsDevice.Adapter.CurrentDisplayMode);
                }

                sb.AppendLine("    GPU status: " + game.GraphicsDevice.GraphicsDeviceStatus);
            }

            sb.AppendLine("\n");
            sb.AppendLine("Exception: " + exception.Message);
            sb.AppendLine("Target site: " + exception.TargetSite.ToString());
            sb.AppendLine("Stack trace: ");
            sb.AppendLine(exception.StackTrace);
            sb.AppendLine("\n");

            sb.AppendLine("Last debug messages:");
            for (int i = DebugConsole.Messages.Count - 1; i > 0; i--)
            {
                sb.AppendLine("[" + DebugConsole.Messages[i].Time + "] " + DebugConsole.Messages[i].Text);
            }

            string crashReport = sb.ToString();

            sw.WriteLine(crashReport);
            sw.Close();

            if (GameSettings.SaveDebugConsoleLogs)
            {
                DebugConsole.SaveLogs();
            }

            if (GameSettings.SendUserStatistics)
            {
                CrashMessageBox("A crash report (\"crashreport.log\") was saved in the root folder of the game and sent to the developers.");
                GameAnalytics.AddErrorEvent(EGAErrorSeverity.Error, crashReport);
                GameAnalytics.OnStop();
            }
            else
            {
                CrashMessageBox("A crash report (\"crashreport.log\") was saved in the root folder of the game. The error was not sent to the developers because user statistics have been disabled, but" +
                                " if you'd like to help fix this bug, you may post it on Barotrauma's GitHub issue tracker: https://github.com/Regalis11/Barotrauma/issues/");
            }
        }
コード例 #20
0
 public void ReportModLoaded(string name)
 {
     GameAnalytics.AddErrorEvent(EGAErrorSeverity.Info, "mod_used: " + name);
 }