Skip to content

Commit

Permalink
remove duplicate code
Browse files Browse the repository at this point in the history
  • Loading branch information
FunkyFr3sh committed Sep 11, 2024
1 parent e029279 commit 8ff40f9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 30 deletions.
1 change: 1 addition & 0 deletions inc/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@


HMODULE WINAPI util_enumerate_modules(_In_opt_ HMODULE hModuleLast);
void util_pull_messages();
FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name);
BOOL util_caller_is_ddraw_wrapper(void* return_address);
BOOL util_is_bad_read_ptr(void* p);
Expand Down
33 changes: 3 additions & 30 deletions src/ddsurface.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "blt.h"
#include "config.h"
#include "ddclipper.h"
#include "utils.h"
#include "versionhelpers.h"


Expand Down Expand Up @@ -50,21 +51,7 @@ HRESULT dds_Blt(
dbg_dump_dds_blt_flags(dwFlags);
dbg_dump_dds_blt_fx_flags((dwFlags & DDBLT_DDFX) && lpDDBltFx ? lpDDBltFx->dwDDFX : 0);

if (g_config.fixnotresponding &&
g_ddraw.hwnd &&
g_ddraw.last_msg_pull_tick + 1000 < timeGetTime() &&
GetCurrentThreadId() == g_ddraw.gui_thread_id &&
!IsWine())
{
/* workaround for "Not Responding" window problem */
//g_ddraw.last_msg_pull_tick = timeGetTime();
MSG msg;
if (real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
}
util_pull_messages();

if (g_ddraw.ref &&
g_ddraw.iskkndx &&
Expand Down Expand Up @@ -998,21 +985,7 @@ HRESULT dds_Lock(

dbg_dump_dds_lock_flags(dwFlags);

if (g_config.fixnotresponding &&
g_ddraw.hwnd &&
g_ddraw.last_msg_pull_tick + 1000 < timeGetTime() &&
GetCurrentThreadId() == g_ddraw.gui_thread_id &&
!IsWine())
{
/* workaround for "Not Responding" window problem */
//g_ddraw.last_msg_pull_tick = timeGetTime();
MSG msg;
if (real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
}
util_pull_messages();

HRESULT ret = dds_GetSurfaceDesc(This, lpDDSurfaceDesc);

Expand Down
21 changes: 21 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "render_d3d9.h"
#include "utils.h"
#include "config.h"
#include "versionhelpers.h"


/*
Expand Down Expand Up @@ -69,6 +70,26 @@ HMODULE WINAPI util_enumerate_modules(_In_opt_ HMODULE hModuleLast)
return NULL;
}

void util_pull_messages()
{
if (g_config.fixnotresponding &&
g_ddraw.hwnd &&
g_ddraw.last_msg_pull_tick &&
g_ddraw.last_msg_pull_tick + 1000 < timeGetTime() &&
GetCurrentThreadId() == g_ddraw.gui_thread_id &&
!IsWine())
{
/* workaround for "Not Responding" window problem */
//g_ddraw.last_msg_pull_tick = timeGetTime();
MSG msg;
if (real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessageA(&msg);
}
}
}

FARPROC util_get_iat_proc(HMODULE mod, char* module_name, char* function_name)
{
if (!mod || mod == INVALID_HANDLE_VALUE)
Expand Down

0 comments on commit 8ff40f9

Please sign in to comment.