summaryrefslogtreecommitdiff
path: root/src/os/windows/crashlog_win.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/os/windows/crashlog_win.cpp')
-rw-r--r--src/os/windows/crashlog_win.cpp92
1 files changed, 44 insertions, 48 deletions
diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp
index 4529491bd..b0667ad8f 100644
--- a/src/os/windows/crashlog_win.cpp
+++ b/src/os/windows/crashlog_win.cpp
@@ -150,7 +150,7 @@ static uint32 CalcCRC(byte *data, uint size, uint32 crc)
return crc;
}
-static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
+static void GetFileInfo(DebugFileInfo *dfi, const wchar_t *filename)
{
HANDLE file;
memset(dfi, 0, sizeof(*dfi));
@@ -183,7 +183,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const TCHAR *filename)
static char *PrintModuleInfo(char *output, const char *last, HMODULE mod)
{
- TCHAR buffer[MAX_PATH];
+ wchar_t buffer[MAX_PATH];
DebugFileInfo dfi;
GetModuleFileName(mod, buffer, MAX_PATH);
@@ -491,7 +491,7 @@ char *CrashLogWindows::AppendDecodedStacktrace(char *buffer, const char *last) c
/* virtual */ int CrashLogWindows::WriteCrashDump(char *filename, const char *filename_last) const
{
int ret = 0;
- HMODULE dbghelp = LoadLibrary(_T("dbghelp.dll"));
+ HMODULE dbghelp = LoadLibrary(L"dbghelp.dll");
if (dbghelp != nullptr) {
typedef BOOL (WINAPI *MiniDumpWriteDump_t)(HANDLE, DWORD, HANDLE,
MINIDUMP_TYPE,
@@ -553,19 +553,19 @@ static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep)
}
if (GamelogTestEmergency()) {
- static const TCHAR _emergency_crash[] =
- _T("A serious fault condition occurred in the game. The game will shut down.\n")
- _T("As you loaded an emergency savegame no crash information will be generated.\n");
- MessageBox(nullptr, _emergency_crash, _T("Fatal Application Failure"), MB_ICONERROR);
+ static const wchar_t _emergency_crash[] =
+ L"A serious fault condition occurred in the game. The game will shut down.\n"
+ L"As you loaded an emergency savegame no crash information will be generated.\n";
+ MessageBox(nullptr, _emergency_crash, L"Fatal Application Failure", MB_ICONERROR);
ExitProcess(3);
}
if (SaveloadCrashWithMissingNewGRFs()) {
- static const TCHAR _saveload_crash[] =
- _T("A serious fault condition occurred in the game. The game will shut down.\n")
- _T("As you loaded an savegame for which you do not have the required NewGRFs\n")
- _T("no crash information will be generated.\n");
- MessageBox(nullptr, _saveload_crash, _T("Fatal Application Failure"), MB_ICONERROR);
+ static const wchar_t _saveload_crash[] =
+ L"A serious fault condition occurred in the game. The game will shut down.\n"
+ L"As you loaded an savegame for which you do not have the required NewGRFs\n"
+ L"no crash information will be generated.\n";
+ MessageBox(nullptr, _saveload_crash, L"Fatal Application Failure", MB_ICONERROR);
ExitProcess(3);
}
@@ -641,20 +641,20 @@ static void CDECL CustomAbort(int signal)
static bool _expanded;
-static const TCHAR _crash_desc[] =
- _T("A serious fault condition occurred in the game. The game will shut down.\n")
- _T("Please send the crash information and the crash.dmp file (if any) to the developers.\n")
- _T("This will greatly help debugging. The correct place to do this is https://github.com/OpenTTD/OpenTTD/issues. ")
- _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");
+static const wchar_t _crash_desc[] =
+ L"A serious fault condition occurred in the game. The game will shut down.\n"
+ L"Please send the crash information and the crash.dmp file (if any) to the developers.\n"
+ L"This will greatly help debugging. The correct place to do this is https://github.com/OpenTTD/OpenTTD/issues. "
+ L"The information contained in the report is displayed below.\n"
+ L"Press \"Emergency save\" to attempt saving the game. Generated file(s):\n"
+ L"%s";
-static const TCHAR _save_succeeded[] =
- _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.");
+static const wchar_t _save_succeeded[] =
+ L"Emergency save succeeded.\nIts location is '%s'.\n"
+ L"Be aware that critical parts of the internal game state may have become "
+ L"corrupted. The saved game is not guaranteed to work.";
-static const TCHAR * const _expand_texts[] = {_T("S&how report >>"), _T("&Hide report <<") };
+static const wchar_t * const _expand_texts[] = {L"S&how report >>", L"&Hide report <<" };
static void SetWndSize(HWND wnd, int mode)
{
@@ -677,17 +677,13 @@ static void SetWndSize(HWND wnd, int mode)
}
}
-/* When TCHAR is char, then _sntprintf becomes snprintf. When TCHAR is wchar it doesn't. Likewise for strcat. */
-#undef snprintf
-#undef strcat
-
static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG: {
/* We need to put the crash-log in a separate buffer because the default
- * buffer in MB_TO_WIDE is not large enough (512 chars) */
- TCHAR crash_msgW[lengthof(CrashLogWindows::current->crashlog)];
+ * buffer in OTTD2FS is not large enough (512 chars) */
+ wchar_t crash_msgW[lengthof(CrashLogWindows::current->crashlog)];
/* Convert unix -> dos newlines because the edit box only supports that properly :( */
const char *unix_nl = CrashLogWindows::current->crashlog;
char dos_nl[lengthof(CrashLogWindows::current->crashlog)];
@@ -700,20 +696,20 @@ 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) + 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);
- _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));
+ size_t len = wcslen(_crash_desc) + 2;
+ len += wcslen(OTTD2FS(CrashLogWindows::current->crashlog_filename)) + 2;
+ len += wcslen(OTTD2FS(CrashLogWindows::current->crashdump_filename)) + 2;
+ len += wcslen(OTTD2FS(CrashLogWindows::current->screenshot_filename)) + 1;
+
+ wchar_t *text = AllocaM(wchar_t, len);
+ _snwprintf(text, len, _crash_desc, OTTD2FS(CrashLogWindows::current->crashlog_filename));
+ if (OTTD2FS(CrashLogWindows::current->crashdump_filename)[0] != L'\0') {
+ wcscat(text, L"\n");
+ wcscat(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));
+ if (OTTD2FS(CrashLogWindows::current->screenshot_filename)[0] != L'\0') {
+ wcscat(text, L"\n");
+ wcscat(text, OTTD2FS(CrashLogWindows::current->screenshot_filename));
}
SetDlgItemText(wnd, 10, text);
@@ -729,12 +725,12 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA
case 13: // Emergency save
char filename[MAX_PATH];
if (CrashLogWindows::current->WriteSavegame(filename, lastof(filename))) {
- size_t len = _tcslen(_save_succeeded) + _tcslen(OTTD2FS(filename)) + 1;
- TCHAR *text = AllocaM(TCHAR, len);
- _sntprintf(text, len, _save_succeeded, OTTD2FS(filename));
- MessageBox(wnd, text, _T("Save successful"), MB_ICONINFORMATION);
+ size_t len = wcslen(_save_succeeded) + wcslen(OTTD2FS(filename)) + 1;
+ wchar_t *text = AllocaM(wchar_t, len);
+ _snwprintf(text, len, _save_succeeded, OTTD2FS(filename));
+ MessageBox(wnd, text, L"Save successful", MB_ICONINFORMATION);
} else {
- MessageBox(wnd, _T("Save failed"), _T("Save failed"), MB_ICONINFORMATION);
+ MessageBox(wnd, L"Save failed", L"Save failed", MB_ICONINFORMATION);
}
break;
case 15: // Expand window to show crash-message