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;
dskWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN);
dskHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN);
// Check for API call failure
if ( (dskWidth == 0) || (dskHeight == 0) )
return false;
*width = dskWidth;
*height = dskHeight;
return true;
// Check that API call succeeded
if ( (dskWidth > 0) && (dskHeight > 0) ) {
*width = dskWidth;
*height = dskHeight;
return true;
}
// Fall back to r_mode if the above fails
}
if (mode == -1) // custom mode