From 5bbe1299d2f7d172ba1c582c6e05d2688cfb1eaa Mon Sep 17 00:00:00 2001 From: FunkyFr3sh Date: Sun, 26 May 2024 09:08:38 +0200 Subject: [PATCH] add test patches for Clue Finders 4th --- inc/wndproc.h | 1 + src/dd.c | 4 +++- src/ddclipper.c | 28 ++++++++++++++++++++++++---- src/ddsurface.c | 14 +++++++++++--- src/wndproc.c | 5 +++++ 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/inc/wndproc.h b/inc/wndproc.h index 3cb6a97..f066a04 100644 --- a/inc/wndproc.h +++ b/inc/wndproc.h @@ -9,6 +9,7 @@ #define WM_DISPLAYCHANGE_DDRAW WM_APP+116 #define WM_TOGGLE_FULLSCREEN WM_APP+117 #define WM_TOGGLE_MAXIMIZE WM_APP+118 +#define WM_ACTIVATEAPP_DDRAW WM_APP+119 #define IDT_TIMER_LEAVE_BNET 541287654 diff --git a/src/dd.c b/src/dd.c index 41aa9aa..709414f 100644 --- a/src/dd.c +++ b/src/dd.c @@ -921,7 +921,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl real_SetWindowLongA( g_ddraw.hwnd, GWL_STYLE, - (real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW) & ~WS_MAXIMIZE); + (real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE) | WS_OVERLAPPEDWINDOW) & ~(WS_MAXIMIZE | WS_SYSMENU)); } LONG exstyle = real_GetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE); @@ -1003,6 +1003,8 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl if (lock_mouse || (g_config.fullscreen && real_GetForegroundWindow() == g_ddraw.hwnd)) mouse_lock(); + + real_SendMessageA(g_ddraw.hwnd, WM_ACTIVATEAPP_DDRAW, 1, 0); } else { diff --git a/src/ddclipper.c b/src/ddclipper.c index 28fc283..72a87e1 100644 --- a/src/ddclipper.c +++ b/src/ddclipper.c @@ -66,25 +66,45 @@ HRESULT ddc_IsClipListChanged(IDirectDrawClipperImpl* This, BOOL FAR* lpbChanged HRESULT ddc_SetClipList(IDirectDrawClipperImpl* This, LPRGNDATA lpClipList, DWORD dwFlags) { - /* Keep this commented out until we found a game that actually needs it if (This->hwnd) return DDERR_CLIPPERISUSINGHWND; if (This->region) DeleteObject(This->region); - if (lpClipList) + if (lpClipList && lpClipList->rdh.nCount >= 1) { - This->region = ExtCreateRegion(NULL, 0, lpClipList); + RECT* rc = (RECT*)lpClipList->Buffer; + + This->region = CreateRectRgnIndirect(&rc[0]); if (!This->region) return DDERR_INVALIDCLIPLIST; + + for (int i = 1; i < lpClipList->rdh.nCount; ++i) + { + HRGN region = CreateRectRgnIndirect(&rc[i]); + + if (!region) + return DDERR_INVALIDCLIPLIST; + + if (CombineRgn(This->region, region, This->region, RGN_OR) == ERROR) + { + DeleteObject(region); + DeleteObject(This->region); + This->region = NULL; + + return DDERR_INVALIDCLIPLIST; + } + + DeleteObject(region); + } } else { This->region = NULL; } - */ + return DD_OK; } diff --git a/src/ddsurface.c b/src/ddsurface.c index 30377ae..7d06d6c 100644 --- a/src/ddsurface.c +++ b/src/ddsurface.c @@ -86,12 +86,13 @@ HRESULT dds_Blt( BOOL is_stretch_blt = src_w != dst_w || src_h != dst_h; - /* Disable this for now (needs more testing) if (This->clipper && !(dwFlags & DDBLT_NO_CLIP) && dst_w > 0 && dst_h > 0) { DWORD size = 0; - if (SUCCEEDED(IDirectDrawClipper_GetClipList(This->clipper, &dst_rect, NULL, &size))) + HRESULT result = IDirectDrawClipper_GetClipList(This->clipper, &dst_rect, NULL, &size); + + if (SUCCEEDED(result)) { RGNDATA* list = (RGNDATA*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size); @@ -122,8 +123,15 @@ HRESULT dds_Blt( return DD_OK; } } + else if (result == DDERR_NOCLIPLIST) + { + return DDERR_NOCLIPLIST; + } + else + { + return DDERR_INVALIDCLIPLIST; + } } - */ if (dst_rect.right < 0) dst_rect.right = 0; diff --git a/src/wndproc.c b/src/wndproc.c index 4f53765..4b80ecb 100644 --- a/src/wndproc.c +++ b/src/wndproc.c @@ -175,6 +175,11 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam uMsg = WM_DISPLAYCHANGE; break; } + case WM_ACTIVATEAPP_DDRAW: + { + uMsg = WM_ACTIVATEAPP; + break; + } case WM_D3D9DEVICELOST: { if (((!g_config.windowed && !g_config.nonexclusive) || !util_is_minimized(g_ddraw.hwnd)) &&