mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
use inline functions for WINE checks
This commit is contained in:
parent
6626480358
commit
e18eb931eb
@ -33,11 +33,6 @@ void verhelp_init();
|
||||
BOOL verhelp_verify_version(PRTL_OSVERSIONINFOEXW versionInfo, ULONG typeMask, ULONGLONG conditionMask);
|
||||
const char* verhelp_wine_get_version();
|
||||
void verhelp_wine_get_host_version(const char** sysname, const char** release);
|
||||
BOOL verhelp_is_wine();
|
||||
BOOL verhelp_is_macos();
|
||||
BOOL verhelp_is_linux();
|
||||
|
||||
/* Original MS Functions */
|
||||
|
||||
VERSIONHELPERAPI IsWindowsVersionOrGreater(DWORD major, DWORD minor, DWORD build, WORD servpack)
|
||||
{
|
||||
@ -111,4 +106,24 @@ VERSIONHELPERAPI IsWindowsServer(void) {
|
||||
return !verhelp_verify_version(&vi, VER_PRODUCT_TYPE, VerSetConditionMask(0, VER_PRODUCT_TYPE, VER_EQUAL));
|
||||
}
|
||||
|
||||
VERSIONHELPERAPI IsWine(void) {
|
||||
return verhelp_wine_get_version() != NULL;
|
||||
}
|
||||
|
||||
VERSIONHELPERAPI IsMacOS(void) {
|
||||
const char* sysname = NULL;
|
||||
const char* release = NULL;
|
||||
verhelp_wine_get_host_version(&sysname, &release);
|
||||
|
||||
return sysname && _strcmpi(sysname, "Darwin") == 0;
|
||||
}
|
||||
|
||||
VERSIONHELPERAPI IsLinux(void) {
|
||||
const char* sysname = NULL;
|
||||
const char* release = NULL;
|
||||
verhelp_wine_get_host_version(&sysname, &release);
|
||||
|
||||
return sysname && _strcmpi(sysname, "Linux") == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1150,7 +1150,7 @@ static DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string,
|
||||
{
|
||||
char buf[MAX_PATH] = { 0 };
|
||||
|
||||
if (verhelp_is_wine())
|
||||
if (IsWine())
|
||||
{
|
||||
char section[MAX_PATH] = { 0 };
|
||||
_snprintf(section, sizeof(section) - 1, "%s/wine", g_config.process_file_name);
|
||||
|
12
src/dd.c
12
src/dd.c
@ -875,7 +875,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
if (g_config.remove_menu && GetMenu(g_ddraw.hwnd))
|
||||
SetMenu(g_ddraw.hwnd, NULL);
|
||||
|
||||
if (!verhelp_is_wine())
|
||||
if (!IsWine())
|
||||
{
|
||||
MSG msg; /* workaround for "Not Responding" window problem in cnc games */
|
||||
real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE | PM_QS_INPUT);
|
||||
@ -905,7 +905,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
real_SetWindowLongA(g_ddraw.hwnd, GWL_EXSTYLE, exstyle & ~(WS_EX_TOOLWINDOW));
|
||||
}
|
||||
|
||||
if (verhelp_is_wine())
|
||||
if (IsWine())
|
||||
{
|
||||
real_SetWindowLongA(
|
||||
g_ddraw.hwnd,
|
||||
@ -1053,7 +1053,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
Fix wayland bug:
|
||||
ChangeDisplaySettings fails silently - enable borderless mode in case display resolution was not changed
|
||||
*/
|
||||
if (verhelp_is_wine() &&
|
||||
if (IsWine() &&
|
||||
(g_ddraw.render.mode.dmPelsWidth != real_GetSystemMetrics(SM_CXSCREEN) ||
|
||||
g_ddraw.render.mode.dmPelsHeight != real_GetSystemMetrics(SM_CYSCREEN)))
|
||||
{
|
||||
@ -1066,7 +1066,7 @@ HRESULT dd_SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBPP, DWORD dwFl
|
||||
}
|
||||
}
|
||||
|
||||
if (verhelp_is_wine())
|
||||
if (IsWine())
|
||||
{
|
||||
real_SetWindowLongA(
|
||||
g_ddraw.hwnd,
|
||||
@ -1273,7 +1273,7 @@ HRESULT dd_WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)
|
||||
if (g_config.maxgameticks == -2)
|
||||
{
|
||||
/* Workaround for DwmFlush() freeze (e.g. slow alt+tab) issue on windows 7 SP1 */
|
||||
if (g_ddraw.renderer == ogl_render_main && !verhelp_is_wine() && !IsWindows8OrGreater())
|
||||
if (g_ddraw.renderer == ogl_render_main && !IsWine() && !IsWindows8OrGreater())
|
||||
{
|
||||
if (fpsl_wait_for_vblank())
|
||||
return DD_OK;
|
||||
@ -1556,7 +1556,7 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute
|
||||
}
|
||||
else /* auto */
|
||||
{
|
||||
if (!verhelp_is_wine() && d3d9_is_available())
|
||||
if (!IsWine() && d3d9_is_available())
|
||||
{
|
||||
g_ddraw.renderer = d3d9_render_main;
|
||||
}
|
||||
|
@ -958,7 +958,7 @@ HRESULT dds_Lock(
|
||||
|
||||
dbg_dump_dds_lock_flags(dwFlags);
|
||||
|
||||
if (g_ddraw.ref && g_config.fixnotresponding && !verhelp_is_wine())
|
||||
if (g_ddraw.ref && g_config.fixnotresponding && !IsWine())
|
||||
{
|
||||
MSG msg; /* workaround for "Not Responding" window problem */
|
||||
real_PeekMessageA(&msg, g_ddraw.hwnd, 0, 0, PM_NOREMOVE);
|
||||
|
@ -131,7 +131,7 @@ void dbg_init()
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
||||
if (verhelp_is_wine())
|
||||
if (IsWine())
|
||||
{
|
||||
TRACE("Wine version = %s\n", verhelp_wine_get_version());
|
||||
|
||||
|
@ -157,7 +157,7 @@ void fpsl_frame_end()
|
||||
(g_config.vsync && (!g_config.maxfps || g_config.maxfps >= g_ddraw.mode.dmDisplayFrequency)))
|
||||
{
|
||||
/* Workaround for DwmFlush() freeze (e.g. slow alt+tab) issue on windows 7 SP1 */
|
||||
if (g_ddraw.renderer == ogl_render_main && !verhelp_is_wine() && !IsWindows8OrGreater())
|
||||
if (g_ddraw.renderer == ogl_render_main && !IsWine() && !IsWindows8OrGreater())
|
||||
{
|
||||
if (fpsl_wait_for_vblank())
|
||||
return;
|
||||
|
@ -213,7 +213,7 @@ void oglu_init()
|
||||
glEnableVertexAttribArray && glUniform2fv && glUniformMatrix4fv && glGenVertexArrays && glBindVertexArray &&
|
||||
glGetUniformLocation;
|
||||
|
||||
if (verhelp_is_wine() && glversion && glversion[0] == '2') // macOS
|
||||
if (IsWine() && glversion && glversion[0] == '2') // macOS
|
||||
{
|
||||
g_oglu_got_version3 = FALSE;
|
||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)xwglGetProcAddress("wglCreateContextAttribsARB");
|
||||
|
@ -47,26 +47,3 @@ void verhelp_wine_get_host_version(const char** sysname, const char** release)
|
||||
if (release)
|
||||
*release = NULL;
|
||||
}
|
||||
|
||||
BOOL verhelp_is_wine()
|
||||
{
|
||||
return wine_get_version != NULL;
|
||||
}
|
||||
|
||||
BOOL verhelp_is_macos()
|
||||
{
|
||||
const char* sysname = NULL;
|
||||
const char* release = NULL;
|
||||
verhelp_wine_get_host_version(&sysname, &release);
|
||||
|
||||
return sysname && _strcmpi(sysname, "Darwin") == 0;
|
||||
}
|
||||
|
||||
BOOL verhelp_is_linux()
|
||||
{
|
||||
const char* sysname = NULL;
|
||||
const char* release = NULL;
|
||||
verhelp_wine_get_host_version(&sysname, &release);
|
||||
|
||||
return sysname && _strcmpi(sysname, "Linux") == 0;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
pos->hwndInsertAfter, pos->x, pos->y, pos->cx, pos->cy);
|
||||
*/
|
||||
|
||||
if (verhelp_is_wine() &&
|
||||
if (IsWine() &&
|
||||
!g_config.windowed &&
|
||||
(pos->x > 0 || pos->y > 0) &&
|
||||
g_ddraw.last_set_window_pos_tick + 500 < timeGetTime())
|
||||
@ -463,7 +463,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
util_update_bnet_pos(x, y);
|
||||
}
|
||||
|
||||
if (in_size_move || (verhelp_is_wine() && !g_config.fullscreen && g_ddraw.render.thread))
|
||||
if (in_size_move || (IsWine() && !g_config.fullscreen && g_ddraw.render.thread))
|
||||
{
|
||||
if (x != -32000)
|
||||
g_config.window_rect.left = x; /* -32000 = Exit/Minimize */
|
||||
@ -480,7 +480,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
}
|
||||
case WM_NCMOUSELEAVE:
|
||||
{
|
||||
if (!verhelp_is_wine()) /* hack: disable aero snap */
|
||||
if (!IsWine()) /* hack: disable aero snap */
|
||||
{
|
||||
LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
|
||||
|
||||
@ -493,7 +493,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
}
|
||||
case WM_SYSCOMMAND:
|
||||
{
|
||||
if ((wParam & ~0x0F) == SC_MOVE && !verhelp_is_wine()) /* hack: disable aero snap */
|
||||
if ((wParam & ~0x0F) == SC_MOVE && !IsWine()) /* hack: disable aero snap */
|
||||
{
|
||||
LONG style = real_GetWindowLongA(g_ddraw.hwnd, GWL_STYLE);
|
||||
|
||||
@ -634,7 +634,7 @@ LRESULT CALLBACK fake_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
|
||||
mouse_unlock();
|
||||
|
||||
if (verhelp_is_wine() && g_ddraw.last_set_window_pos_tick + 500 > timeGetTime())
|
||||
if (IsWine() && g_ddraw.last_set_window_pos_tick + 500 > timeGetTime())
|
||||
return 0;
|
||||
|
||||
if (!g_config.windowed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user