diff options
author | darkvater <darkvater@openttd.org> | 2004-09-23 21:14:20 +0000 |
---|---|---|
committer | darkvater <darkvater@openttd.org> | 2004-09-23 21:14:20 +0000 |
commit | f3758d133a2a0330cdaee175383807bac0ad0249 (patch) | |
tree | aa2a36ed9fc21776897ac8ece0176964b2798d57 /win32.c | |
parent | d72abf6c3ed68fe8e410f29458211aa04521c4ab (diff) | |
download | openttd-f3758d133a2a0330cdaee175383807bac0ad0249.tar.xz |
(svn r312) -Fix: [926105] ctrl + d bug. Longest outstanding bug has been fixed \o/ 2004-03-30 (Tron)
-Fix: [1030393] some screensizes crashes OTTD. Fix in general bug that only allows resolutions which were multiple of 8 in width and height. Also use closest possible resolution in fullscreen if window size is not a valid resolution (Tron)
Diffstat (limited to 'win32.c')
-rw-r--r-- | win32.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -340,8 +340,8 @@ static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP w = r->right - r->left - (r2.right - r2.left); h = r->bottom - r->top - (r2.bottom - r2.top); if (_wnd.double_size) { w >>= 1; h >>= 1; } - w = clamp(w & ~0x7, 64, MAX_SCREEN_WIDTH); - h = clamp(h & ~0x7, 64, MAX_SCREEN_HEIGHT); + w = clamp(w, 64, MAX_SCREEN_WIDTH); + h = clamp(h, 64, MAX_SCREEN_HEIGHT); if (_wnd.double_size) { w <<= 1; h <<= 1; } SetRect(&r2, 0, 0, w, h); @@ -506,13 +506,14 @@ static bool AllocateDibSection(int w, int h) BITMAPINFO *bi; HDC dc; - w = clamp(w & ~7, 64, MAX_SCREEN_WIDTH); - h = clamp(h & ~7, 64, MAX_SCREEN_HEIGHT); + w = clamp(w, 64, MAX_SCREEN_WIDTH); + h = clamp(h, 64, MAX_SCREEN_HEIGHT); if (w == _screen.width && h == _screen.height) return false; - _screen.width = _screen.pitch = w; + _screen.width = w; + _screen.pitch = (w + 3) & ~0x3; _screen.height = h; if (_wnd.alloced_bits) { @@ -524,17 +525,16 @@ static bool AllocateDibSection(int w, int h) memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256); bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - { - if (_wnd.double_size) { - _wnd.alloced_bits = _wnd.buffer_bits = (byte*)malloc(w * h); - w *= 2; - h *= 2; - } - - bi->bmiHeader.biWidth = _wnd.width = w; - bi->bmiHeader.biHeight = -(_wnd.height = h); + if (_wnd.double_size) { + w = (w + 3) & ~0x3; + _wnd.alloced_bits = _wnd.buffer_bits = (byte*)malloc(w * h); + w *= 2; + h *= 2; } + bi->bmiHeader.biWidth = _wnd.width = w; + bi->bmiHeader.biHeight = -(_wnd.height = h); + bi->bmiHeader.biPlanes = 1; bi->bmiHeader.biBitCount = 8; bi->bmiHeader.biCompression = BI_RGB; |