DXGL r649 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r648‎ | r649 | r650 >
Date:01:32, 26 January 2016
Author:admin
Status:new
Tags:
Comment:
Fix EnumSurfaces on DDraw 1 through 4
Modified paths:
  • /ddraw/glDirectDraw.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirectDraw.cpp
@@ -2228,16 +2228,20 @@
22292229 {
22302230 TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDSD,14,lpContext,14,lpEnumSurfacesCallback);
22312231 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2232 - if (!lpDDSD)TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
2233 - if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2232+ if(lpDDSD)
 2233+ if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
22342234 LPVOID context[2];
22352235 context[0] = lpEnumSurfacesCallback;
22362236 context[1] = lpContext;
2237 - DDSURFACEDESC2 ddsd;
2238 - ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
2239 - memcpy(&ddsd, lpDDSD, sizeof(DDSURFACEDESC));
2240 - ddsd.dwSize = sizeof(DDSURFACEDESC2);
2241 - TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, &ddsd, context, EnumSurfacesCallback1));
 2237+ if (lpDDSD)
 2238+ {
 2239+ DDSURFACEDESC2 ddsd;
 2240+ ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
 2241+ memcpy(&ddsd, lpDDSD, sizeof(DDSURFACEDESC));
 2242+ ddsd.dwSize = sizeof(DDSURFACEDESC2);
 2243+ TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, &ddsd, context, EnumSurfacesCallback1));
 2244+ }
 2245+ else TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, NULL, context, EnumSurfacesCallback1));
22422246 }
22432247 HRESULT WINAPI glDirectDraw1::FlipToGDISurface()
22442248 {
@@ -2429,16 +2433,20 @@
24302434 {
24312435 TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDSD,14,lpContext,14,lpEnumSurfacesCallback);
24322436 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2433 - if (!lpDDSD)TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
2434 - if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2437+ if (lpDDSD)
 2438+ if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
24352439 LPVOID context[2];
24362440 context[0] = lpEnumSurfacesCallback;
24372441 context[1] = lpContext;
2438 - DDSURFACEDESC2 ddsd;
2439 - ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
2440 - memcpy(&ddsd, lpDDSD, sizeof(DDSURFACEDESC));
2441 - ddsd.dwSize = sizeof(DDSURFACEDESC2);
2442 - TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, &ddsd, context, EnumSurfacesCallback1));
 2442+ if (lpDDSD)
 2443+ {
 2444+ DDSURFACEDESC2 ddsd;
 2445+ ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
 2446+ memcpy(&ddsd, lpDDSD, sizeof(DDSURFACEDESC));
 2447+ ddsd.dwSize = sizeof(DDSURFACEDESC2);
 2448+ TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, &ddsd, context, EnumSurfacesCallback1));
 2449+ }
 2450+ else TRACE_RET(HRESULT, 23, glDD7->EnumSurfaces(dwFlags, NULL, context, EnumSurfacesCallback1));
24432451 }
24442452 HRESULT WINAPI glDirectDraw2::FlipToGDISurface()
24452453 {
@@ -2657,8 +2665,8 @@
26582666 {
26592667 TRACE_ENTER(5,14,this,9,dwFlags,14,lpDDSD,14,lpContext,14,lpEnumSurfacesCallback);
26602668 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
2661 - if (!lpDDSD)TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
2662 - if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
 2669+ if(lpDDSD)
 2670+ if (lpDDSD->dwSize != sizeof(DDSURFACEDESC)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
26632671 LPVOID context[2];
26642672 context[0] = lpEnumSurfacesCallback;
26652673 context[1] = lpContext;