1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-14 22:03:27 +01:00

remove dont_emulate_dc setting

This commit is contained in:
FunkyFr3sh 2023-07-31 09:17:57 +02:00
parent 2ee0767520
commit 63257823b1
5 changed files with 17 additions and 9 deletions

View File

@ -180,7 +180,6 @@ typedef struct CNCDDRAW
DWORD gui_thread_id;
BOOL rgb555;
BOOL hook_peekmessage;
BOOL dont_emulate_dc;
} CNCDDRAW;

View File

@ -37,5 +37,6 @@ HRESULT dds_SetSurfaceDesc(IDirectDrawSurfaceImpl* This, LPDDSURFACEDESC2 lpDDSD
void* dds_GetBuffer(IDirectDrawSurfaceImpl* This);
HRESULT dd_CreateSurface(IDirectDrawImpl* This, LPDDSURFACEDESC lpDDSurfaceDesc, IDirectDrawSurfaceImpl** lpDDSurface, IUnknown FAR* unkOuter);
extern LONG g_dds_gdi_handles;
#endif

View File

@ -92,6 +92,7 @@ ULONG __stdcall IDirectDrawSurface__Release(IDirectDrawSurfaceImpl* This)
if (This->bitmap)
{
DeleteObject(This->bitmap);
InterlockedDecrement(&g_dds_gdi_handles);
}
else if (This->surface && !This->custom_buf)
{
@ -99,7 +100,10 @@ ULONG __stdcall IDirectDrawSurface__Release(IDirectDrawSurfaceImpl* This)
}
if (This->hdc)
{
DeleteDC(This->hdc);
InterlockedDecrement(&g_dds_gdi_handles);
}
if (This->bmi)
HeapFree(GetProcessHeap(), 0, This->bmi);

View File

@ -55,7 +55,6 @@ void cfg_load()
g_ddraw->opengl_core = cfg_get_bool("opengl_core", FALSE);
g_ddraw->rgb555 = cfg_get_bool("rgb555", FALSE);
g_ddraw->hook_peekmessage = cfg_get_bool("hook_peekmessage", FALSE);
g_ddraw->dont_emulate_dc = cfg_get_bool("dont_emulate_dc", FALSE);
cfg_get_string("screenshotdir", ".\\Screenshots\\", g_ddraw->screenshot_dir, sizeof(g_ddraw->screenshot_dir));
if (g_ddraw->locktopleft)
@ -380,7 +379,6 @@ static void cfg_create_ini()
"hook_peekmessage=false\n"
"dinput_show_cursor=false\n"
"no_dinput_hook=false\n"
"dont_emulate_dc=false\n"
"\n"
"\n"
"\n"
@ -809,10 +807,6 @@ static void cfg_create_ini()
"renderer=opengl\n"
"noactivateapp=true\n"
"\n"
"; Hooligans: Storm over Europe\n"
"[Hooligans]\n"
"dont_emulate_dc=true\n"
"\n"
"; Invictus\n"
"[Invictus]\n"
"adjmouse=true\n"

View File

@ -12,6 +12,8 @@
#include "blt.h"
LONG g_dds_gdi_handles;
HRESULT dds_AddAttachedSurface(IDirectDrawSurfaceImpl* This, IDirectDrawSurfaceImpl* lpDDSurface)
{
if (lpDDSurface)
@ -1205,6 +1207,7 @@ HRESULT dds_SetSurfaceDesc(IDirectDrawSurfaceImpl* This, LPDDSURFACEDESC2 lpDDSD
if (This->bitmap)
{
DeleteObject(This->bitmap);
InterlockedDecrement(&g_dds_gdi_handles);
This->bitmap = NULL;
}
else if (This->surface && !This->custom_buf)
@ -1216,6 +1219,7 @@ HRESULT dds_SetSurfaceDesc(IDirectDrawSurfaceImpl* This, LPDDSURFACEDESC2 lpDDSD
if (This->hdc)
{
DeleteDC(This->hdc);
InterlockedDecrement(&g_dds_gdi_handles);
This->hdc = NULL;
}
@ -1432,10 +1436,13 @@ HRESULT dd_CreateSurface(
}
if (!g_ddraw->dont_emulate_dc)
if (InterlockedExchangeAdd(&g_dds_gdi_handles, 0) < 4000 || (dst_surface->caps & DDSCAPS_PRIMARYSURFACE))
{
dst_surface->hdc = CreateCompatibleDC(g_ddraw->render.hdc);
if (dst_surface->hdc)
InterlockedIncrement(&g_dds_gdi_handles);
dst_surface->mapping =
CreateFileMappingA(
INVALID_HANDLE_VALUE,
@ -1472,6 +1479,9 @@ HRESULT dd_CreateSurface(
(void**)&dst_surface->surface,
dst_surface->mapping,
map_offset);
if (dst_surface->bitmap)
InterlockedIncrement(&g_dds_gdi_handles);
}
dst_surface->bmi->bmiHeader.biHeight = -((int)dst_surface->height);
@ -1489,7 +1499,7 @@ HRESULT dd_CreateSurface(
{
g_ddraw->primary = dst_surface;
FakePrimarySurface = dst_surface->surface;
}
}
}
if (dst_surface->flags & DDSD_BACKBUFFERCOUNT)