1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-25 01:57:47 +01:00

move is_wine bool to g_config

This commit is contained in:
FunkyFr3sh 2023-11-04 03:20:30 +01:00
parent f79b7db8cd
commit e9b585f440
7 changed files with 15 additions and 13 deletions

View File

@ -16,6 +16,7 @@ typedef struct CNCDDRAWCONFIG
char process_file_name[MAX_PATH]; char process_file_name[MAX_PATH];
char process_file_ext[MAX_PATH]; char process_file_ext[MAX_PATH];
INIFILE ini; INIFILE ini;
BOOL is_wine;
/* Optional settings */ /* Optional settings */

View File

@ -124,7 +124,6 @@ typedef struct CNCDDRAW
BOOL iscnc1; BOOL iscnc1;
BOOL iskkndx; BOOL iskkndx;
LONG upscale_hack_active; LONG upscale_hack_active;
BOOL wine;
HCURSOR old_cursor; HCURSOR old_cursor;
int show_cursor_count; int show_cursor_count;
BOOL alt_key_down; BOOL alt_key_down;

View File

@ -1067,6 +1067,8 @@ static void cfg_create_ini()
static void cfg_init() static void cfg_init()
{ {
g_config.is_wine = real_GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_version") != 0;
/* get process filename and directory */ /* get process filename and directory */
if (GetModuleFileNameA(NULL, g_config.game_path, sizeof(g_config.game_path) - 1) > 0) if (GetModuleFileNameA(NULL, g_config.game_path, sizeof(g_config.game_path) - 1) > 0)
{ {

View File

@ -855,7 +855,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
if (g_config.remove_menu && GetMenu(g_ddraw->hwnd)) if (g_config.remove_menu && GetMenu(g_ddraw->hwnd))
SetMenu(g_ddraw->hwnd, NULL); SetMenu(g_ddraw->hwnd, NULL);
if (!g_ddraw->wine) if (!g_config.is_wine)
{ {
MSG msg; /* workaround for "Not Responding" window problem in cnc games */ MSG msg; /* workaround for "Not Responding" window problem in cnc games */
real_PeekMessageA(&msg, g_ddraw->hwnd, 0, 0, PM_NOREMOVE | PM_QS_INPUT); real_PeekMessageA(&msg, g_ddraw->hwnd, 0, 0, PM_NOREMOVE | PM_QS_INPUT);
@ -888,7 +888,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
real_SetWindowLongA(g_ddraw->hwnd, GWL_EXSTYLE, exstyle & ~(WS_EX_TOOLWINDOW)); real_SetWindowLongA(g_ddraw->hwnd, GWL_EXSTYLE, exstyle & ~(WS_EX_TOOLWINDOW));
} }
if (g_ddraw->wine) if (g_config.is_wine)
{ {
real_SetWindowLongA( real_SetWindowLongA(
g_ddraw->hwnd, g_ddraw->hwnd,
@ -1015,7 +1015,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
return dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, dwFlags); return dd_SetDisplayMode(dwWidth, dwHeight, dwBPP, dwFlags);
} }
if (g_ddraw->wine) if (g_config.is_wine)
{ {
real_SetWindowLongA( real_SetWindowLongA(
g_ddraw->hwnd, g_ddraw->hwnd,
@ -1391,7 +1391,6 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
InitializeCriticalSection(&g_ddraw->cs); InitializeCriticalSection(&g_ddraw->cs);
g_ddraw->render.sem = CreateSemaphore(NULL, 0, 1, NULL); g_ddraw->render.sem = CreateSemaphore(NULL, 0, 1, NULL);
g_ddraw->wine = real_GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_version") != 0;
g_blt_use_avx = util_is_avx_supported(); g_blt_use_avx = util_is_avx_supported();
if (g_config.minfps > 1000) if (g_config.minfps > 1000)
@ -1473,7 +1472,7 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
} }
else /* auto */ else /* auto */
{ {
if (!g_ddraw->wine && d3d9_is_available()) if (!g_config.is_wine && d3d9_is_available())
{ {
g_ddraw->renderer = d3d9_render_main; g_ddraw->renderer = d3d9_render_main;
} }

View File

@ -955,7 +955,7 @@ HRESULT dds_Lock(
dbg_dump_dds_lock_flags(dwFlags); dbg_dump_dds_lock_flags(dwFlags);
if (g_ddraw && g_config.fixnotresponding && !g_ddraw->wine) if (g_ddraw && g_config.fixnotresponding && !g_config.is_wine)
{ {
MSG msg; /* workaround for "Not Responding" window problem */ MSG msg; /* workaround for "Not Responding" window problem */
real_PeekMessageA(&msg, g_ddraw->hwnd, 0, 0, PM_NOREMOVE); real_PeekMessageA(&msg, g_ddraw->hwnd, 0, 0, PM_NOREMOVE);

View File

@ -4,6 +4,7 @@
#include "dd.h" #include "dd.h"
#include "debug.h" #include "debug.h"
#include "hook.h" #include "hook.h"
#include "config.h"
PFNWGLCREATECONTEXTPROC xwglCreateContext; PFNWGLCREATECONTEXTPROC xwglCreateContext;
PFNWGLDELETECONTEXTPROC xwglDeleteContext; PFNWGLDELETECONTEXTPROC xwglDeleteContext;
@ -211,7 +212,7 @@ void oglu_init()
glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray && glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray &&
glGetUniformLocation; glGetUniformLocation;
if (g_ddraw->wine && glversion && glversion[0] == '2') // macOS if (g_config.is_wine && glversion && glversion[0] == '2') // macOS
{ {
g_oglu_got_version3 = FALSE; g_oglu_got_version3 = FALSE;
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB"); wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB");

View File

@ -228,7 +228,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
pos->hwndInsertAfter, pos->x, pos->y, pos->cx, pos->cy); pos->hwndInsertAfter, pos->x, pos->y, pos->cx, pos->cy);
*/ */
if (g_ddraw->wine && if (g_config.is_wine &&
!g_config.windowed && !g_config.windowed &&
(pos->x > 0 || pos->y > 0) && (pos->x > 0 || pos->y > 0) &&
g_ddraw->last_set_window_pos_tick + 500 < timeGetTime()) g_ddraw->last_set_window_pos_tick + 500 < timeGetTime())
@ -460,7 +460,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
util_update_bnet_pos(x, y); util_update_bnet_pos(x, y);
} }
if (in_size_move || (g_ddraw->wine && !g_config.fullscreen && g_ddraw->render.thread)) if (in_size_move || (g_config.is_wine && !g_config.fullscreen && g_ddraw->render.thread))
{ {
if (x != -32000) if (x != -32000)
g_config.window_rect.left = x; /* -32000 = Exit/Minimize */ g_config.window_rect.left = x; /* -32000 = Exit/Minimize */
@ -477,7 +477,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
} }
case WM_NCMOUSELEAVE: case WM_NCMOUSELEAVE:
{ {
if (!g_ddraw->wine) /* hack: disable aero snap */ if (!g_config.is_wine) /* hack: disable aero snap */
{ {
LONG style = real_GetWindowLongA(g_ddraw->hwnd, GWL_STYLE); LONG style = real_GetWindowLongA(g_ddraw->hwnd, GWL_STYLE);
@ -490,7 +490,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
} }
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
{ {
if ((wParam & ~0x0F) == SC_MOVE && !g_ddraw->wine) /* hack: disable aero snap */ if ((wParam & ~0x0F) == SC_MOVE && !g_config.is_wine) /* hack: disable aero snap */
{ {
LONG style = real_GetWindowLongA(g_ddraw->hwnd, GWL_STYLE); LONG style = real_GetWindowLongA(g_ddraw->hwnd, GWL_STYLE);
@ -594,7 +594,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
mouse_unlock(); mouse_unlock();
if (g_ddraw->wine && g_ddraw->last_set_window_pos_tick + 500 > timeGetTime()) if (g_config.is_wine && g_ddraw->last_set_window_pos_tick + 500 > timeGetTime())
return 0; return 0;
if (!g_config.windowed) if (!g_config.windowed)