1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Fixed GetAttachedSurface when DDSCAPS_3DDEVICE is suppressed

Fixes a crash in Colin McRae Rally (#232).
This commit is contained in:
narzoul 2023-07-23 00:13:06 +02:00
parent 3b8ff67cc4
commit 383ffd28b9
3 changed files with 17 additions and 0 deletions

View File

@ -60,6 +60,7 @@ namespace
SET_COMPAT_METHOD(Blt);
SET_COMPAT_METHOD(BltFast);
SET_COMPAT_METHOD(Flip);
SET_COMPAT_METHOD(GetAttachedSurface);
SET_COMPAT_METHOD(GetCaps);
SET_COMPAT_METHOD(GetDC);
SET_COMPAT_METHOD(GetPalette);

View File

@ -150,6 +150,21 @@ namespace DDraw
return getOrigVtable(This).Flip(This, lpDDSurfaceTargetOverride, dwFlags);
}
template <typename TSurface>
HRESULT SurfaceImpl<TSurface>::GetAttachedSurface(TSurface* This, TDdsCaps* lpDDSCaps, TSurface** lplpDDAttachedSurface)
{
TDdsCaps caps = {};
if (lpDDSCaps && (lpDDSCaps->dwCaps & DDSCAPS_3DDEVICE) &&
SUCCEEDED(getOrigVtable(This).GetCaps(This, &caps)) &&
!(caps.dwCaps & DDSCAPS_3DDEVICE) && (m_data->m_origCaps & DDSCAPS_3DDEVICE))
{
caps = *lpDDSCaps;
caps.dwCaps &= ~DDSCAPS_3DDEVICE;
return getOrigVtable(This).GetAttachedSurface(This, &caps, lplpDDAttachedSurface);
}
return getOrigVtable(This).GetAttachedSurface(This, lpDDSCaps, lplpDDAttachedSurface);
}
template <typename TSurface>
TSurface* SurfaceImpl<TSurface>::getBltSrc(TSurface* src)
{

View File

@ -29,6 +29,7 @@ namespace DDraw
virtual HRESULT BltFast(TSurface* This, DWORD dwX, DWORD dwY,
TSurface* lpDDSrcSurface, LPRECT lpSrcRect, DWORD dwTrans);
virtual HRESULT Flip(TSurface* This, TSurface* lpDDSurfaceTargetOverride, DWORD dwFlags);
virtual HRESULT GetAttachedSurface(TSurface* This, TDdsCaps* lpDDSCaps, TSurface** lplpDDAttachedSurface);
virtual HRESULT GetCaps(TSurface* This, TDdsCaps* lpDDSCaps);
virtual HRESULT GetDC(TSurface* This, HDC* lphDC);
virtual HRESULT GetPalette(TSurface* This, LPDIRECTDRAWPALETTE* lplpDDPalette);