Beispiel #1
0
 private void Start()
 {
     GameAnalytics.Initialize();
 }
Beispiel #2
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());
            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:");
            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();
        }
Beispiel #3
0
 static void AddGASystemTracker()
 {
     if (Object.FindObjectOfType(typeof(GameAnalytics)) == null)
     {
         GameObject go = PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath(GameAnalytics.WhereIs("GameAnalytics.prefab"), typeof(GameObject))) as GameObject;
         go.name = "GameAnalytics";
         Selection.activeObject = go;
         Undo.RegisterCreatedObjectUndo(go, "Created GameAnalytics Object");
     }
     else
     {
         Debug.LogWarning("A GameAnalytics object already exists in this scene - you should never have more than one per scene!");
     }
 }
Beispiel #4
0
 public void Restart()
 {
     FindObjectOfType <AudioManager>().Play("UI-Click");
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "Game-Restart");
 }
    public void RestartGame(string playerName)
    {
#if !UNITY_EDITOR
        GameAnalytics.NewDesignEvent("RestartGame:playerName ");
#endif
    }
 private void AboutBtn_Click(object sender, RoutedEventArgs e)
 {
     GameAnalytics.AddDesignEvent("AboutDialogOpen");
     aboutDialog = Dialog.Show(new AboutDialog(this));
 }
Beispiel #7
0
        private void SetGADOTProgress(string[] names)
        {
#if GA
            _gaProgressFormat[0] = null;
            _gaProgressFormat[1] = null;
            _gaProgressFormat[2] = null;
            _gaProgressFormat[3] = null;
            _gaProgressFormat[4] = null;

            //Status
            if (names[2].Equals("enter"))
            {
                _gaProgressFormat[0] = GAProgressionStatus.Start;   //装拆箱过程,尽量避免
            }
            else if (names[2].Equals("win"))
            {
                _gaProgressFormat[0] = GAProgressionStatus.Complete;   //装拆箱过程,尽量避免
                if (names[0].Equals("level"))
                {
                    _gaProgressFormat[4] = names[3] ?? null;
                }
            }
            else if (names[2].Equals("fail"))
            {
                _gaProgressFormat[0] = GAProgressionStatus.Fail;   //装拆箱过程,尽量避免
            }
            else
            {
                _gaProgressFormat[0] = GAProgressionStatus.Complete;   //装拆箱过程,尽量避免
            }
            //progress01
            _gaProgressFormat[1] = names[1];
            //progress02
            _gaProgressFormat[2] = names[2];

            //以LEVEL开头
            if (names[0].Equals("level"))
            {
                //progress03
                _gaProgressFormat[3] = string.Format("progress");
            }
            else if (names[0].Equals("ui"))
            {
                //progress03
                _gaProgressFormat[3] = names.Length > 3 ? names[3] : names[2];
            }

            //Debug.LogWarning("<color=yellow>====ProgressEvent====</color>");
            //for (int i = 0; i < _gaProgressFormat.Length; i++)
            //{
            //    Debug.LogWarning(_gaProgressFormat[i]);
            //}

            //if (_gaProgressFormat[4] != null)
            //{
            //    Debug.Log(">>>>>>>>>>>>>>>>>>>>>>SetGADOT  _gaProgressFormat >>>>>>" + Convert.ToInt32(_gaProgressFormat[4]));
            //}
            if (_gaProgressFormat[4] != null)
            {
                GameAnalytics.NewProgressionEvent(
                    ( GAProgressionStatus )_gaProgressFormat[0],
                    ( string )_gaProgressFormat[1],
                    ( string )_gaProgressFormat[2],
                    ( string )_gaProgressFormat[3],
                    Convert.ToInt32(_gaProgressFormat[4])
                    );
            }
            else
            {
                GameAnalytics.NewProgressionEvent(
                    ( GAProgressionStatus )_gaProgressFormat[0],
                    ( string )_gaProgressFormat[1],
                    ( string )_gaProgressFormat[2],
                    ( string )_gaProgressFormat[3]
                    );
            }
#endif
        }
Beispiel #8
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() ?? ExtractEngineFromLua(ver) ?? 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);
            }
        }
Beispiel #9
0
 private void Awake()
 {
     GameAnalytics.ChannelId = SdkU3d.getChannel();
     GameAnalytics.analytics = this;
 }
Beispiel #10
0
 private void OnDestroy()
 {
     if (GameAnalytics.account != null)
     {
         TalkingDataGA.OnEnd();
     }
     GameAnalytics.analytics = null;
     GameAnalytics.account = null;
     GameAnalytics.accountIDCache = string.Empty;
 }
Beispiel #11
0
 public static void OnReward(double virtualCurrencyAmount, GameAnalytics.VirtualCurrencyReward reason)
 {
     if (!GameAnalytics.IsValide())
     {
         return;
     }
     TDGAVirtualCurrency.OnReward(virtualCurrencyAmount, reason.ToString());
 }
Beispiel #12
0
 public static void OnPurchase(GameAnalytics.PurchaseType type, double priceInVirtualCurrency)
 {
     if (!GameAnalytics.IsValide())
     {
         return;
     }
     TDGAItem.OnPurchase(type.ToString(), 1, priceInVirtualCurrency);
 }
Beispiel #13
0
 public static void OnPurchase(GameAnalytics.PurchaseType type, string itemName, int itemNumber, double priceInVirtualCurrency)
 {
     if (!GameAnalytics.IsValide())
     {
         return;
     }
     TDGAItem.OnPurchase(string.Format("{0}#{1}", type, itemName), itemNumber, priceInVirtualCurrency);
 }
Beispiel #14
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);
        }
 void Start()
 {
     InitializeFacebook();
     ConnectTenjin();
     GameAnalytics.Initialize();
 }
Beispiel #16
0
        public void Run()
        {
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));

            TryStartChildServerRelay();
            Init();
            StartServer();

            ResetFrameTime();

            double frequency = (double)Stopwatch.Frequency;

            if (frequency <= 1500)
            {
                DebugConsole.NewMessage("WARNING: Stopwatch frequency under 1500 ticks per second. Expect significant syncing accuracy issues.", Color.Yellow);
            }

            stopwatch = Stopwatch.StartNew();
            long prevTicks = stopwatch.ElapsedTicks;

            while (ShouldRun)
            {
                long   currTicks   = stopwatch.ElapsedTicks;
                double elapsedTime = Math.Max(currTicks - prevTicks, 0) / frequency;
                Timing.Accumulator += elapsedTime;
                if (Timing.Accumulator > 1.0)
                {
                    //prevent spiral of death
                    Timing.Accumulator = Timing.Step;
                }
                prevTicks = currTicks;
                while (Timing.Accumulator >= Timing.Step)
                {
                    Timing.TotalTime += Timing.Step;
                    DebugConsole.Update();
                    if (GameSession?.GameMode == null || !GameSession.GameMode.Paused)
                    {
                        Screen.Selected?.Update((float)Timing.Step);
                    }
                    Server.Update((float)Timing.Step);
                    if (Server == null)
                    {
                        break;
                    }
                    SteamManager.Update((float)Timing.Step);
                    TaskPool.Update();
                    CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);

                    Timing.Accumulator -= Timing.Step;
                }

#if !DEBUG
                if (Server?.OwnerConnection == null)
                {
                    DebugConsole.UpdateCommandLine((int)(Timing.Accumulator * 800));
                }
                else
                {
                    DebugConsole.Clear();
                }
#else
                DebugConsole.UpdateCommandLine((int)(Timing.Accumulator * 800));
#endif

                int frameTime = (int)(((double)(stopwatch.ElapsedTicks - prevTicks) / frequency) * 1000.0);
                frameTime = Math.Max(0, frameTime);

                Thread.Sleep(Math.Max(((int)(Timing.Step * 1000.0) - frameTime) / 2, 0));
            }
            stopwatch.Stop();

            CloseServer();

            SteamManager.ShutDown();

            SaveUtil.CleanUnnecessarySaveFiles();

            if (GameSettings.SaveDebugConsoleLogs)
            {
                DebugConsole.SaveLogs();
            }
            if (GameSettings.SendUserStatistics)
            {
                GameAnalytics.OnQuit();
            }

            MainThread = null;
        }
Beispiel #17
0
 public static void EndSession()
 {
     GameAnalytics.EndSession();
 }
Beispiel #18
0
 public static void OnFailScene(SceneInfo sceneInfo, GameAnalytics.ESceneFailed cause)
 {
     if (!GameAnalytics.IsValide())
     {
         return;
     }
     TDGAMission.OnFailed(GameAnalytics.GetSceneLogName(sceneInfo), cause.ToString());
 }
Beispiel #19
0
 private void HandleLevelFinished()
 {
     GameAnalytics.NewDesignEvent("Level Finished", levelLoaderService.CurrentLevel);
 }
 private void UnrealNetworkProfilerMainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     GameAnalytics.EndSession();
 }
    [Range(30,100)]
    public int resolutionPercentage=75;

    private void Start()
    {
        if (!FB.IsInitialized)
        {
            // Initialize the Facebook SDK
            FB.Init(InitCallback);
        }

        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
            SetResolution();
            GameAnalytics.Initialize();
            DontDestroyOnLoad(this.gameObject);
        }
    }
 public void CloseAboutDialog()
 {
     GameAnalytics.AddDesignEvent("AboutDialogClose");
     aboutDialog.Close();
 }
 // es punqcia gamoidzaxe wagebis dros
 public void GameOverEvent(float score)
 {
     GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, "game", (int)score);
 }
Beispiel #24
0
 private void Awake()
 {
     GameAnalytics.Initialize();
 }
 // es punqcia gamoidzaxe dawyebis dros
 public void StartEvent()
 {
     GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "game");
 }
Beispiel #26
0
 public void DanceOff()
 {
     FindObjectOfType <AudioManager>().Play("UI-Click");
     GameAnalytics.NewProgressionEvent(GAProgressionStatus.Start, "DanceDance");
     SceneManager.LoadScene(2);
 }
 public void HighScoreEvent(int score)
 {
     GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, "highscore", (int)score);
 }
 public void OnRemoteConfigsUpdated()
 {
     GameAnalytics.RemoteConfigsUpdated();
 }
 public void SubmitScoreForAnalytics(int score)
 {
     GameAnalytics.NewProgressionEvent(GAProgressionStatus.Complete, "game", score);
 }
Beispiel #30
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);
                }
            }
        }
 public void OnCommandCenterUpdated()
 {
     GameAnalytics.CommandCenterUpdated();
 }
Beispiel #32
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 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);
            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);
            }

            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.", 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);
            }
        }
    public void TotalApplicationTime()
    {
#if !UNITY_EDITOR
        GameAnalytics.NewResourceEvent(GAResourceFlowType.Source, "TimeOpened", Time.time, "Game_Time", "ApplicationTime_Total");
#endif
    }
Beispiel #34
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 + " (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.Critical, 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/");
            }
        }
    public void TotalGameTime()
    {
#if !UNITY_EDITOR
        GameAnalytics.NewResourceEvent(GAResourceFlowType.Source, "GameTime", Time.timeSinceLevelLoad, "Game_Time", "LevelTime_Total");
#endif
    }
Beispiel #36
0
        public void Run()
        {
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Item));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Items.Components.ItemComponent));
            Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Hull));

            Init();
            StartServer();

            ResetFrameTime();

            double frequency = (double)Stopwatch.Frequency;

            if (frequency <= 1500)
            {
                DebugConsole.NewMessage("WARNING: Stopwatch frequency under 1500 ticks per second. Expect significant syncing accuracy issues.", Color.Yellow);
            }

            stopwatch = Stopwatch.StartNew();
            long prevTicks = stopwatch.ElapsedTicks;

            while (ShouldRun)
            {
                long   currTicks   = stopwatch.ElapsedTicks;
                double elapsedTime = Math.Max(currTicks - prevTicks, 0) / frequency;
                Timing.Accumulator += elapsedTime;
                if (Timing.Accumulator > 1.0)
                {
                    //prevent spiral of death
                    Timing.Accumulator = Timing.Step;
                }
                Timing.TotalTime += elapsedTime;
                prevTicks         = currTicks;
                while (Timing.Accumulator >= Timing.Step)
                {
                    DebugConsole.Update();
                    if (Screen.Selected != null)
                    {
                        Screen.Selected.Update((float)Timing.Step);
                    }
                    Server.Update((float)Timing.Step);
                    SteamManager.Update((float)Timing.Step);
                    CoroutineManager.Update((float)Timing.Step, (float)Timing.Step);

                    Timing.Accumulator -= Timing.Step;
                }
                int frameTime = (int)(((double)(stopwatch.ElapsedTicks - prevTicks) / frequency) * 1000.0);
                frameTime = Math.Max(0, frameTime);
                Thread.Sleep(Math.Max(((int)(Timing.Step * 1000.0) - frameTime) / 2, 0));
            }
            stopwatch.Stop();

            CloseServer();

            SteamManager.ShutDown();
            if (GameSettings.SendUserStatistics)
            {
                GameAnalytics.OnQuit();
            }
        }
Beispiel #37
0
 public static void OnFailScene(string missionId, GameAnalytics.ESceneFailed cause)
 {
     if (!GameAnalytics.IsValide())
     {
         return;
     }
     TDGAMission.OnFailed(missionId, cause.ToString());
 }