From 1584e061ebcabea80970955337473b8a6733ebab Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 8 Feb 2007 10:04:57 +0000 Subject: [PATCH] (svn r8624) [0.5] -Backport from trunk (8239, 8240, 8315): -Regression (r7278): Help window was empty for UNICODE builds -Fix (r8013): Put the output of -h to stdout and not to stderr (through ShowInfo) -Fix: use ShowInfo over fprintf(stderr, as Windows doesn't always have a stderr visible/available --- gfxinit.c | 2 +- openttd.c | 6 ++++++ win32.c | 10 +++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gfxinit.c b/gfxinit.c index a74074268c..0ef43acdd0 100644 --- a/gfxinit.c +++ b/gfxinit.c @@ -145,7 +145,7 @@ static bool FileMD5(const MD5File file, bool warn) while ((len = fread(buffer, 1, sizeof(buffer), f)) != 0) md5_append(&filemd5state, buffer, len); - if (ferror(f) && warn) fprintf(stderr, "Error Reading from %s \n", buf); + if (ferror(f) && warn) ShowInfoF("Error Reading from %s \n", buf); fclose(f); md5_finish(&filemd5state, digest); diff --git a/openttd.c b/openttd.c index 74969ac488..f4804dee99 100644 --- a/openttd.c +++ b/openttd.c @@ -163,7 +163,13 @@ static void showhelp(void) p = GetDriverList(p, lastof(buf)); + /* ShowInfo put output to stderr, but version information should go + * to stdout; this is the only exception */ +#if !defined(WIN32) && !defined(WIN64) + printf("%s\n", buf); +#else ShowInfo(buf); +#endif } diff --git a/win32.c b/win32.c index 2b6a4f696a..7acc12ab4c 100644 --- a/win32.c +++ b/win32.c @@ -369,7 +369,7 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM l case WM_INITDIALOG: { #if defined(UNICODE) /* We need to put the crash-log in a seperate buffer because the default - * buffer in MB_TO_WIDE is not large enough (256 chars) */ + * buffer in MB_TO_WIDE is not large enough (512 chars) */ wchar_t crash_msgW[8096]; #endif SetDlgItemText(wnd, 10, _crash_desc); @@ -839,12 +839,16 @@ void ShowInfo(const char *str) fprintf(stderr, "%s\n", str); } else { bool old; - +#if defined(UNICODE) + /* We need to put the text in a seperate buffer because the default + * buffer in MB_TO_WIDE might not be large enough (512 chars) */ + wchar_t help_msgW[4096]; +#endif ReleaseCapture(); _left_button_clicked =_left_button_down = false; old = MyShowCursor(true); - if (MessageBox(GetActiveWindow(), MB_TO_WIDE(str), _T("OpenTTD"), MB_ICONINFORMATION | MB_OKCANCEL) == IDCANCEL) { + if (MessageBox(GetActiveWindow(), MB_TO_WIDE_BUFFER(str, help_msgW, lengthof(help_msgW)), _T("OpenTTD"), MB_ICONINFORMATION | MB_OKCANCEL) == IDCANCEL) { CreateConsole(); } MyShowCursor(old);