From 86b9dd3e7fc3ac50ce08779978c2b0958fb3f751 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Fri, 4 Mar 2016 22:22:42 +0100
Subject: ddraw: Set ddsOldCaps correctly in ddraw7_GetCaps.

---
 dlls/ddraw/ddraw.c        |  2 ++
 dlls/ddraw/tests/ddraw1.c | 26 ++++++++++++++++++++++++++
 dlls/ddraw/tests/ddraw2.c | 26 ++++++++++++++++++++++++++
 dlls/ddraw/tests/ddraw4.c | 26 ++++++++++++++++++++++++++
 dlls/ddraw/tests/ddraw7.c | 26 ++++++++++++++++++++++++++
 5 files changed, 106 insertions(+)

diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index f9231d8..eeb941c 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -1532,6 +1532,8 @@ static HRESULT WINAPI ddraw7_GetCaps(IDirectDraw7 *iface, DDCAPS *DriverCaps, DD
     caps.dwCaps |= DDCAPS_ALIGNSTRIDE;
     caps.dwAlignStrideAlign = DDRAW_STRIDE_ALIGNMENT;
 
+    caps.ddsOldCaps.dwCaps = caps.ddsCaps.dwCaps;
+
     IDirect3D7_EnumZBufferFormats(&ddraw->IDirect3D7_iface, &IID_IDirect3DHALDevice, enum_zbuffer, &caps);
 
     if(DriverCaps)
diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index 02eb9c9..e48307b 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -8573,6 +8573,31 @@ static void test_blt(void)
     DestroyWindow(window);
 }
 
+static void test_caps(void)
+{
+    IDirectDraw *ddraw;
+    DDCAPS caps, caps2;
+    HRESULT hr;
+
+    ddraw = create_ddraw();
+    ok(!!ddraw, "Failed to create a ddraw object.\n");
+
+    caps.dwSize = sizeof(caps);
+    caps2.dwSize = sizeof(caps2);
+    hr = IDirectDraw_GetCaps(ddraw, &caps, &caps2);
+    ok(SUCCEEDED(hr), "Failed to query for caps, hr %#x.\n", hr);
+
+    ok(caps.ddsOldCaps.dwCaps == caps.ddsCaps.dwCaps,
+       "Expected hal ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps.ddsOldCaps.dwCaps, caps.ddsCaps.dwCaps);
+
+    ok(caps2.ddsOldCaps.dwCaps == caps2.ddsCaps.dwCaps,
+       "Expected hel ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps2.ddsOldCaps.dwCaps, caps2.ddsCaps.dwCaps);
+
+    IDirectDraw_Release(ddraw);
+}
+
 START_TEST(ddraw1)
 {
     IDirectDraw *ddraw;
@@ -8650,4 +8675,5 @@ START_TEST(ddraw1)
     test_offscreen_overlay();
     test_overlay_rect();
     test_blt();
+    test_caps();
 }
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index ee3508f..719b8ef 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -9680,6 +9680,31 @@ static void test_blt(void)
     DestroyWindow(window);
 }
 
+static void test_caps(void)
+{
+    IDirectDraw2 *ddraw;
+    DDCAPS caps, caps2;
+    HRESULT hr;
+
+    ddraw = create_ddraw();
+    ok(!!ddraw, "Failed to create a ddraw object.\n");
+
+    caps.dwSize = sizeof(caps);
+    caps2.dwSize = sizeof(caps2);
+    hr = IDirectDraw2_GetCaps(ddraw, &caps, &caps2);
+    ok(SUCCEEDED(hr), "Failed to query for caps, hr %#x.\n", hr);
+
+    ok(caps.ddsOldCaps.dwCaps == caps.ddsCaps.dwCaps,
+       "Expected hal ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps.ddsOldCaps.dwCaps, caps.ddsCaps.dwCaps);
+
+    ok(caps2.ddsOldCaps.dwCaps == caps2.ddsCaps.dwCaps,
+       "Expected hel ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps2.ddsOldCaps.dwCaps, caps2.ddsCaps.dwCaps);
+
+    IDirectDraw2_Release(ddraw);
+}
+
 START_TEST(ddraw2)
 {
     IDirectDraw2 *ddraw;
@@ -9764,4 +9789,5 @@ START_TEST(ddraw2)
     test_offscreen_overlay();
     test_overlay_rect();
     test_blt();
+    test_caps();
 }
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 6f863b1..a48e3b7 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -10858,6 +10858,31 @@ static void test_blt(void)
     DestroyWindow(window);
 }
 
+static void test_caps(void)
+{
+    IDirectDraw4 *ddraw;
+    DDCAPS caps, caps2;
+    HRESULT hr;
+
+    ddraw = create_ddraw();
+    ok(!!ddraw, "Failed to create a ddraw object.\n");
+
+    caps.dwSize = sizeof(caps);
+    caps2.dwSize = sizeof(caps2);
+    hr = IDirectDraw4_GetCaps(ddraw, &caps, &caps2);
+    ok(SUCCEEDED(hr), "Failed to query for caps, hr %#x.\n", hr);
+
+    ok(caps.ddsOldCaps.dwCaps == caps.ddsCaps.dwCaps,
+       "Expected hal ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps.ddsOldCaps.dwCaps, caps.ddsCaps.dwCaps);
+
+    ok(caps2.ddsOldCaps.dwCaps == caps2.ddsCaps.dwCaps,
+       "Expected hel ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps2.ddsOldCaps.dwCaps, caps2.ddsCaps.dwCaps);
+
+    IDirectDraw4_Release(ddraw);
+}
+
 START_TEST(ddraw4)
 {
     IDirectDraw4 *ddraw;
@@ -10949,4 +10974,5 @@ START_TEST(ddraw4)
     test_offscreen_overlay();
     test_overlay_rect();
     test_blt();
+    test_caps();
 }
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 72ec446..68115b7 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -11149,6 +11149,31 @@ static void test_blt(void)
     DestroyWindow(window);
 }
 
+static void test_caps(void)
+{
+    IDirectDraw7 *ddraw;
+    DDCAPS caps, caps2;
+    HRESULT hr;
+
+    ddraw = create_ddraw();
+    ok(!!ddraw, "Failed to create a ddraw object.\n");
+
+    caps.dwSize = sizeof(caps);
+    caps2.dwSize = sizeof(caps2);
+    hr = IDirectDraw7_GetCaps(ddraw, &caps, &caps2);
+    ok(SUCCEEDED(hr), "Failed to query for caps, hr %#x.\n", hr);
+
+    ok(caps.ddsOldCaps.dwCaps == caps.ddsCaps.dwCaps,
+       "Expected hal ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps.ddsOldCaps.dwCaps, caps.ddsCaps.dwCaps);
+
+    ok(caps2.ddsOldCaps.dwCaps == caps2.ddsCaps.dwCaps,
+       "Expected hel ddsOldCaps and ddsCaps to be identical (%x vs %x).\n",
+       caps2.ddsOldCaps.dwCaps, caps2.ddsCaps.dwCaps);
+
+    IDirectDraw7_Release(ddraw);
+}
+
 START_TEST(ddraw7)
 {
     HMODULE module = GetModuleHandleA("ddraw.dll");
@@ -11251,4 +11276,5 @@ START_TEST(ddraw7)
     test_offscreen_overlay();
     test_overlay_rect();
     test_blt();
+    test_caps();
 }
-- 
2.7.1

