diff options
author | glx <glx@openttd.org> | 2009-11-19 16:27:15 +0000 |
---|---|---|
committer | glx <glx@openttd.org> | 2009-11-19 16:27:15 +0000 |
commit | 2535b1afcf6139c2daf16b9bdb4af38dd71279e1 (patch) | |
tree | 056f69f26e6d42b369286e3b720ca00c97e96c3d /src/os/windows/crashlog_win.cpp | |
parent | 68400db74938e5e6190a7b4ec0643de745d73461 (diff) | |
download | openttd-2535b1afcf6139c2daf16b9bdb4af38dd71279e1.tar.xz |
(svn r18184) -Codechange: add crash screenshot for win32
Diffstat (limited to 'src/os/windows/crashlog_win.cpp')
-rw-r--r-- | src/os/windows/crashlog_win.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 11acad0ab..cf17615c9 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -44,6 +44,8 @@ public: char crashlog_filename[MAX_PATH]; /** Buffer for the filename of the crash dump */ char crashdump_filename[MAX_PATH]; + /** Buffer for the filename of the crash screenshot */ + char screenshot_filename[MAX_PATH]; /** * A crash log is always generated when it's generated. @@ -55,6 +57,7 @@ public: this->crashlog[0] = '\0'; this->crashlog_filename[0] = '\0'; this->crashdump_filename[0] = '\0'; + this->screenshot_filename[0] = '\0'; } /** @@ -380,6 +383,7 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep) log->FillCrashLog(log->crashlog, lastof(log->crashlog)); log->WriteCrashLog(log->crashlog, log->crashlog_filename, lastof(log->crashlog_filename)); log->WriteCrashDump(log->crashdump_filename, lastof(log->crashdump_filename)); + log->WriteScreenshot(log->screenshot_filename, lastof(log->screenshot_filename)); /* Close any possible log files */ CloseConsoleLogIfActive(); @@ -430,10 +434,10 @@ static const TCHAR _crash_desc[] = _T("This will greatly help debugging. The correct place to do this is http://bugs.openttd.org. ") _T("The information contained in the report is displayed below.\n") _T("Press \"Emergency save\" to attempt saving the game. Generated file(s):\n") - _T("'%s%s%s'"); + _T("%s"); static const TCHAR _save_succeeded[] = - _T("Emergency save succeeded. Its location is '%s'.\n") + _T("Emergency save succeeded.\nIts location is '%s'.\n") _T("Be aware that critical parts of the internal game state may have become ") _T("corrupted. The saved game is not guaranteed to work."); @@ -481,11 +485,21 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA *p = '\0'; /* Add path to crash.log and crash.dmp (if any) to the crash window text */ - size_t len = _tcslen(_crash_desc) + _tcslen(OTTD2FS(CrashLogWindows::current->crashlog_filename)) + _tcslen(OTTD2FS(CrashLogWindows::current->crashdump_filename)) + 4; + size_t len = _tcslen(_crash_desc) + 2; + len += _tcslen(OTTD2FS(CrashLogWindows::current->crashlog_filename)) + 2; + len += _tcslen(OTTD2FS(CrashLogWindows::current->crashdump_filename)) + 2; + len += _tcslen(OTTD2FS(CrashLogWindows::current->screenshot_filename)) + 1; + TCHAR *text = AllocaM(TCHAR, len); - TCHAR *dump = _tcsdup(OTTD2FS(CrashLogWindows::current->crashdump_filename)); - _sntprintf(text, len, _crash_desc, OTTD2FS(CrashLogWindows::current->crashlog_filename), dump[0] != _T('\0') ? _T("'\n'") : _T(""), dump); - free(dump); + _sntprintf(text, len, _crash_desc, OTTD2FS(CrashLogWindows::current->crashlog_filename)); + if (OTTD2FS(CrashLogWindows::current->crashdump_filename)[0] != _T('\0')) { + _tcscat(text, _T("\n")); + _tcscat(text, OTTD2FS(CrashLogWindows::current->crashdump_filename)); + } + if (OTTD2FS(CrashLogWindows::current->screenshot_filename)[0] != _T('\0')) { + _tcscat(text, _T("\n")); + _tcscat(text, OTTD2FS(CrashLogWindows::current->screenshot_filename)); + } SetDlgItemText(wnd, 10, text); SetDlgItemText(wnd, 11, MB_TO_WIDE_BUFFER(dos_nl, crash_msgW, lengthof(crash_msgW))); |