From 39912b7bdee684ea838303ec5fb1513977131b74 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 30 Apr 2012 16:48:47 +0000 Subject: (svn r24188) -Fix-ish [FS#5151] (r1): when changing the basics of a window (fullscreen, 8bpp/32bpp), and a window already exists, it was forced out of maximize mode, and its resolution/position was reset, often causing unwanted side-effects. As a "bonus", a WC_SIZE was triggered, and if the system was going from 8bpp to 32pp, this caused a forced window update in a limbo-state of the blitter (not fully 32bpp just yet, but for sure no longer 8bpp); this could cause random memory access which could lead to ACCESS_VIOLATIONS --- src/video/win32_v.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 270af12e8..d83395795 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -319,15 +319,13 @@ bool VideoDriver_Win32::MakeWindow(bool full_screen) #if !defined(WINCE) AdjustWindowRect(&r, style, FALSE); #endif - w = r.right - r.left; - h = r.bottom - r.top; - x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; - y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; - - if (_wnd.main_wnd) { - ShowWindow(_wnd.main_wnd, SW_SHOWNORMAL); // remove maximize-flag - SetWindowPos(_wnd.main_wnd, 0, x, y, w, h, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); - } else { + + if (_wnd.main_wnd == NULL) { + w = r.right - r.left; + h = r.bottom - r.top; + x = (GetSystemMetrics(SM_CXSCREEN) - w) / 2; + y = (GetSystemMetrics(SM_CYSCREEN) - h) / 2; + TCHAR Windowtitle[50]; _sntprintf(Windowtitle, lengthof(Windowtitle), _T("OpenTTD %s"), MB_TO_WIDE(_openttd_revision)); -- cgit v1.2.3-70-g09d2