Fall back to using r_mode when GetSystemMetrics() API calls fail in win32/vid_dll.c->VID_GetModeInfo().

Previous handling of API call failure could cause repeat returns of false, resulting in a fatal error.
This commit is contained in:
Knightmare66 2021-11-01 21:51:39 -04:00
parent d552aa1e48
commit 304e3e30c4

View file

@ -565,14 +565,13 @@ qboolean VID_GetModeInfo (int *width, int *height, int mode)
int dskWidth=0, dskHeight=0; int dskWidth=0, dskHeight=0;
dskWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); dskWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
dskHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); dskHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
// Check for API call failure // Check that API call succeeded
if ( (dskWidth == 0) || (dskHeight == 0) ) if ( (dskWidth > 0) && (dskHeight > 0) ) {
return false; *width = dskWidth;
*height = dskHeight;
*width = dskWidth; return true;
*height = dskHeight; }
// Fall back to r_mode if the above fails
return true;
} }
if (mode == -1) // custom mode if (mode == -1) // custom mode