private void HandleGameProcessExited()
        {
            Disable();
            if (nativeCursorUsed)
            {
                Game.IsMouseVisible = true;
            }
            else
            {
                WindowManager.Cursor.Visible = true;
            }
            ProgramConstants.IsInGame = false;
            Game.TargetElapsedTime    = TimeSpan.FromMilliseconds(1000.0 / UserINISettings.Instance.ClientFPS);
            if (UserINISettings.Instance.MinimizeWindowsOnGameStart)
            {
                WindowManager.MaximizeWindow();
            }

            UserINISettings.Instance.ReloadSettings();

            if (UserINISettings.Instance.BorderlessWindowedClient)
            {
                // Hack: Re-set graphics mode
                // Windows resizes our window if we're in fullscreen mode and
                // the in-game resolution is lower than the user's desktop resolution.
                // After the game exits, Windows doesn't properly re-size our window
                // back to cover the entire screen, which causes graphics to get
                // stretched and also messes up input handling since the window manager
                // still thinks it's using the original resolution.
                // Re-setting the graphics mode fixes it.
                GameClass.SetGraphicsMode(WindowManager);
            }

            DateTime dtn = DateTime.Now;

            if (deletingLogFilesFailed)
            {
                return;
            }

            CopyErrorLog(ProgramConstants.ClientUserFilesPath + "GameCrashLogs", "EXCEPT.TXT", dtn);
            CopySyncErrorLogs(ProgramConstants.ClientUserFilesPath + "SyncErrorLogs", dtn);
        }
示例#2
0
        private void HandleGameProcessExited()
        {
            Visible = false;
            Enabled = false;
            if (nativeCursorUsed)
            {
                Game.IsMouseVisible = true;
            }
            else
            {
                WindowManager.Cursor.Visible = true;
            }
            ProgramConstants.IsInGame = false;
            Game.TargetElapsedTime    = TimeSpan.FromMilliseconds(1000.0 / UserINISettings.Instance.ClientFPS);
            if (UserINISettings.Instance.MinimizeWindowsOnGameStart)
            {
                WindowManager.MaximizeWindow();
            }

            UserINISettings.Instance.ReloadSettings();

            if (UserINISettings.Instance.BorderlessWindowedClient)
            {
                // Hack: Re-set graphics mode
                // Windows resizes our window if we're in fullscreen mode and
                // the in-game resolution is lower than the user's desktop resolution.
                // After the game exits, Windows doesn't properly re-size our window
                // back to cover the entire screen, which causes graphics to get
                // stretched and also messes up input handling since the window manager
                // still thinks it's using the original resolution.
                // Re-setting the graphics mode fixes it.
                GameClass.SetGraphicsMode(WindowManager);
            }

            DateTime dtn = DateTime.Now;

#if ARES
            Task.Factory.StartNew(ProcessScreenshots);

            // TODO: Ares debug log handling should be addressed in Ares DLL itself.
            // For now the following are handled here:
            // 1. Make a copy of syringe.log in debug snapshot directory on both crash and desync.
            // 2. Move SYNCX.txt from game directory to debug snapshot directory on desync.
            // 3. Make a debug snapshot directory & copy debug.log to it on desync even if full crash dump wasn't created.
            // 4. Handle the empty snapshot directories created on a crash if debug logging was disabled.

            string snapshotDirectory = GetNewestDebugSnapshotDirectory();
            bool   snapshotCreated   = snapshotDirectory != null;

            snapshotDirectory = snapshotDirectory ?? ProgramConstants.GamePath + "debug/snapshot-" +
                                dtn.ToString("yyyyMMdd-HHmmss");

            bool     debugLogModified = false;
            string   debugLogPath     = ProgramConstants.GamePath + "debug/debug.log";
            DateTime lastWriteTime    = new DateTime();

            if (File.Exists(debugLogPath))
            {
                lastWriteTime = File.GetLastWriteTimeUtc(debugLogPath);
            }

            if (!lastWriteTime.Equals(debugLogLastWriteTime))
            {
                debugLogModified      = true;
                debugLogLastWriteTime = lastWriteTime;
            }

            if (CopySyncErrorLogs(snapshotDirectory, null) || snapshotCreated)
            {
                if (File.Exists(debugLogPath) && !File.Exists(snapshotDirectory + "/debug.log") && debugLogModified)
                {
                    File.Copy(debugLogPath, snapshotDirectory + "/debug.log");
                }

                CopyErrorLog(snapshotDirectory, "syringe.log", null);
            }
#else
            if (deletingLogFilesFailed)
            {
                return;
            }

            CopyErrorLog(ProgramConstants.ClientUserFilesPath + "GameCrashLogs", "EXCEPT.TXT", dtn);
            CopySyncErrorLogs(ProgramConstants.ClientUserFilesPath + "SyncErrorLogs", dtn);
#endif
        }
        private void HandleGameProcessExited()
        {
            Visible = false;
            Enabled = false;
            if (nativeCursorUsed)
            {
                Game.IsMouseVisible = true;
            }
            else
            {
                WindowManager.Cursor.Visible = true;
            }
            ProgramConstants.IsInGame = false;
            Game.TargetElapsedTime    = TimeSpan.FromMilliseconds(1000.0 / FPS);
            if (UserINISettings.Instance.MinimizeWindowsOnGameStart)
            {
                WindowManager.MaximizeWindow();
            }

            UserINISettings.Instance.ReloadSettings();

            if (deletingLogFilesFailed)
            {
                return;
            }

            if (UserINISettings.Instance.BorderlessWindowedClient)
            {
                // Hack: Re-set graphics mode
                // Windows resizes our window if we're in fullscreen mode and
                // the in-game resolution is lower than the user's desktop resolution.
                // After the game exits, Windows doesn't properly re-size our window
                // back to cover the entire screen, which causes graphics to get
                // stretched and also messes up input handling since the window manager
                // still thinks it's using the original resolution.
                // Re-setting the graphics mode fixes it.
                GameClass.SetGraphicsMode(WindowManager);
            }

            try
            {
                if (!Directory.Exists(ProgramConstants.GamePath + "Client/ErrorLogs"))
                {
                    Directory.CreateDirectory(ProgramConstants.GamePath + "Client/ErrorLogs");
                }

                DateTime dtn = DateTime.Now;

                if (File.Exists(ProgramConstants.GamePath + "EXCEPT.TXT"))
                {
                    Logger.Log("The game crashed! Copying EXCEPT.TXT file.");

                    File.Copy(ProgramConstants.GamePath + "EXCEPT.TXT",
                              string.Format(ProgramConstants.GamePath + "Client/ErrorLogs/EXCEPT_{0}_{1}_{2}_{3}_{4}.TXT",
                                            dtn.Day, dtn.Month, dtn.Year, dtn.Hour, dtn.Minute));
                }

                for (int i = 0; i < 8; i++)
                {
                    string syncFileName = "SYNC" + i + ".TXT";

                    if (File.Exists(ProgramConstants.GamePath + syncFileName))
                    {
                        Logger.Log("There was a sync error! Copying file " + syncFileName);

                        File.Copy(ProgramConstants.GamePath + syncFileName,
                                  string.Format(ProgramConstants.GamePath + "Client/ErrorLogs/" + syncFileName + "_{0}_{1}_{2}_{3}_{4}.TXT",
                                                dtn.Day, dtn.Month, dtn.Year, dtn.Hour, dtn.Minute));
                        File.Delete(ProgramConstants.GamePath + syncFileName);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log("An error occured while checking for EXCEPT.TXT and SYNCX.TXT files. Message: " + ex.Message);
            }
        }