limit available resolutions to avoid crashes (Infantry Online)
This commit is contained in:
parent
befbb19a2e
commit
1fb996d8a2
3 changed files with 41 additions and 0 deletions
37
src/dd.c
37
src/dd.c
|
@ -26,6 +26,7 @@ HRESULT dd_EnumDisplayModes(
|
|||
dbg_dump_edm_flags(dwFlags);
|
||||
|
||||
DWORD i = 0;
|
||||
DWORD res_count = 0;
|
||||
DDSURFACEDESC2 s;
|
||||
|
||||
/* Some games crash when you feed them with too many resolutions so we have to keep the list short */
|
||||
|
@ -144,6 +145,12 @@ HRESULT dd_EnumDisplayModes(
|
|||
|
||||
if (g_ddraw->bpp == 8 || g_ddraw->resolutions == RESLIST_FULL)
|
||||
{
|
||||
if (g_ddraw->max_resolutions && res_count++ >= g_ddraw->max_resolutions)
|
||||
{
|
||||
TRACE(" resolution limit reached, stopping\n");
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
if (lpEnumModesCallback((LPDDSURFACEDESC)&s, lpContext) == DDENUMRET_CANCEL)
|
||||
{
|
||||
TRACE(" DDENUMRET_CANCEL returned, stopping\n");
|
||||
|
@ -160,6 +167,12 @@ HRESULT dd_EnumDisplayModes(
|
|||
|
||||
if (g_ddraw->bpp == 16 || g_ddraw->resolutions == RESLIST_FULL)
|
||||
{
|
||||
if (g_ddraw->max_resolutions && res_count++ >= g_ddraw->max_resolutions)
|
||||
{
|
||||
TRACE(" resolution limit reached, stopping\n");
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
if (lpEnumModesCallback((LPDDSURFACEDESC)&s, lpContext) == DDENUMRET_CANCEL)
|
||||
{
|
||||
TRACE(" DDENUMRET_CANCEL returned, stopping\n");
|
||||
|
@ -176,6 +189,12 @@ HRESULT dd_EnumDisplayModes(
|
|||
|
||||
if (g_ddraw->bpp == 32 || g_ddraw->resolutions == RESLIST_FULL)
|
||||
{
|
||||
if (g_ddraw->max_resolutions && res_count++ >= g_ddraw->max_resolutions)
|
||||
{
|
||||
TRACE(" resolution limit reached, stopping\n");
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
if (lpEnumModesCallback((LPDDSURFACEDESC)&s, lpContext) == DDENUMRET_CANCEL)
|
||||
{
|
||||
TRACE(" DDENUMRET_CANCEL returned, stopping\n");
|
||||
|
@ -233,6 +252,12 @@ HRESULT dd_EnumDisplayModes(
|
|||
s.dwWidth = resolutions[i].cx;
|
||||
s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3;
|
||||
|
||||
if (g_ddraw->max_resolutions && res_count++ >= g_ddraw->max_resolutions)
|
||||
{
|
||||
TRACE(" resolution limit reached, stopping\n");
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
if (lpEnumModesCallback((LPDDSURFACEDESC)&s, lpContext) == DDENUMRET_CANCEL)
|
||||
{
|
||||
TRACE(" DDENUMRET_CANCEL returned, stopping\n");
|
||||
|
@ -246,6 +271,12 @@ HRESULT dd_EnumDisplayModes(
|
|||
s.ddpfPixelFormat.dwBBitMask = 0x001F;
|
||||
s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3;
|
||||
|
||||
if (g_ddraw->max_resolutions && res_count++ >= g_ddraw->max_resolutions)
|
||||
{
|
||||
TRACE(" resolution limit reached, stopping\n");
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
if (lpEnumModesCallback((LPDDSURFACEDESC)&s, lpContext) == DDENUMRET_CANCEL)
|
||||
{
|
||||
TRACE(" DDENUMRET_CANCEL returned, stopping\n");
|
||||
|
@ -262,6 +293,12 @@ HRESULT dd_EnumDisplayModes(
|
|||
s.ddpfPixelFormat.dwBBitMask = 0x0000FF;
|
||||
s.lPitch = ((s.dwWidth * s.ddpfPixelFormat.dwRGBBitCount + 31) & ~31) >> 3;
|
||||
|
||||
if (g_ddraw->max_resolutions && res_count++ >= g_ddraw->max_resolutions)
|
||||
{
|
||||
TRACE(" resolution limit reached, stopping\n");
|
||||
return DD_OK;
|
||||
}
|
||||
|
||||
if (lpEnumModesCallback((LPDDSURFACEDESC)&s, lpContext) == DDENUMRET_CANCEL)
|
||||
{
|
||||
TRACE(" DDENUMRET_CANCEL returned, stopping\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue