(svn r8624) [0.5] -Backport from trunk (8239, 8240, 8315): 0.5
authorrubidium
Thu, 08 Feb 2007 10:04:57 +0000
branch0.5
changeset 5428 ef4e98d1a511
parent 5427 63ce73145566
child 5429 a1f3d6573141
(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
openttd.c
win32.c
--- a/gfxinit.c	Thu Feb 08 10:00:22 2007 +0000
+++ b/gfxinit.c	Thu Feb 08 10:04:57 2007 +0000
@@ -145,7 +145,7 @@
 		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);
--- a/openttd.c	Thu Feb 08 10:00:22 2007 +0000
+++ b/openttd.c	Thu Feb 08 10:04:57 2007 +0000
@@ -163,7 +163,13 @@
 
 	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
 }
 
 
--- a/win32.c	Thu Feb 08 10:00:22 2007 +0000
+++ b/win32.c	Thu Feb 08 10:04:57 2007 +0000
@@ -369,7 +369,7 @@
 		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 @@
 		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);