(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
This commit is contained in:
rubidium 2007-02-08 10:04:57 +00:00
parent 03bfa6e525
commit 1584e061eb
3 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -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
}

10
win32.c
View File

@ -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);