diff --git a/inc/config.h b/inc/config.h index bf2df31..97d9755 100644 --- a/inc/config.h +++ b/inc/config.h @@ -39,13 +39,12 @@ typedef struct CNCDDRAWCONFIG BOOL noactivateapp; int maxgameticks; + int minfps; BOOL nonexclusive; BOOL singlecpu; int resolutions; int fixchilds; BOOL hook_peekmessage; - int minfps; - DWORD minfps_tick_len; /* Undocumented settings */ diff --git a/inc/dd.h b/inc/dd.h index 46a95b1..1d0aa8f 100644 --- a/inc/dd.h +++ b/inc/dd.h @@ -140,6 +140,7 @@ typedef struct CNCDDRAW DWORD last_set_window_pos_tick; /* WINE hack */ SPEEDLIMITER ticks_limiter; SPEEDLIMITER flip_limiter; + DWORD minfps_tick_len; DWORD gui_thread_id; BOOL show_driver_warning; BOOL d3d9on12; diff --git a/src/config.c b/src/config.c index 3f00c17..cb8b656 100644 --- a/src/config.c +++ b/src/config.c @@ -56,24 +56,13 @@ void cfg_load() GET_BOOL(g_config.noactivateapp, "noactivateapp", FALSE); GET_INT(g_config.maxgameticks, "maxgameticks", 0); + GET_INT(g_config.minfps, "minfps", 0); GET_BOOL(g_config.nonexclusive, "nonexclusive", FALSE); GET_BOOL(g_config.singlecpu, "singlecpu", TRUE); GET_INT(g_config.resolutions, "resolutions", RESLIST_NORMAL); GET_INT(g_config.fixchilds, "fixchilds", FIX_CHILDS_DETECT_PAINT); GET_BOOL(g_config.hook_peekmessage, "hook_peekmessage", FALSE); - GET_INT(g_config.minfps, "minfps", 0); - - if (g_config.minfps > 1000) - { - g_config.minfps = 1000; - } - - if (g_config.minfps > 0) - { - g_config.minfps_tick_len = (DWORD)(1000.0f / g_config.minfps); - } - /* Undocumented settings */ GET_BOOL(g_config.releasealt, "releasealt", FALSE); @@ -113,10 +102,7 @@ void cfg_load() GET_BOOL(g_config.stronghold_hack, "stronghold_hack", FALSE); GET_BOOL(g_config.mgs_hack, "mgs_hack", FALSE); - if (g_config.infantryhack) - { - GameHandlesClose = TRUE; - } + GameHandlesClose = GameHandlesClose || g_config.infantryhack; } void cfg_save() diff --git a/src/dd.c b/src/dd.c index b6241f8..eec1c62 100644 --- a/src/dd.c +++ b/src/dd.c @@ -1378,6 +1378,12 @@ HRESULT dd_CreateEx(GUID* lpGuid, LPVOID* lplpDD, REFIID iid, IUnknown* pUnkOute g_ddraw->wine = real_GetProcAddress(GetModuleHandleA("ntdll.dll"), "wine_get_version") != 0; g_blt_use_avx = util_is_avx_supported(); + if (g_config.minfps > 1000) + g_config.minfps = 1000; + + if (g_config.minfps > 0) + g_ddraw->minfps_tick_len = (DWORD)(1000.0f / g_config.minfps); + /* can't fully set it up here due to missing g_ddraw->mode.dmDisplayFrequency */ g_fpsl.htimer = CreateWaitableTimer(NULL, TRUE, NULL); diff --git a/src/render_d3d9.c b/src/render_d3d9.c index 82b1d64..66511ad 100644 --- a/src/render_d3d9.c +++ b/src/render_d3d9.c @@ -454,7 +454,7 @@ DWORD WINAPI d3d9_render_main(void) BOOL needs_update = FALSE; - DWORD timeout = g_config.minfps > 0 ? g_config.minfps_tick_len : INFINITE; + DWORD timeout = g_config.minfps > 0 ? g_ddraw->minfps_tick_len : INFINITE; while (g_ddraw->render.run && (g_config.minfps < 0 || WaitForSingleObject(g_ddraw->render.sem, timeout) != WAIT_FAILED)) diff --git a/src/render_gdi.c b/src/render_gdi.c index 89b0502..c3f339f 100644 --- a/src/render_gdi.c +++ b/src/render_gdi.c @@ -38,7 +38,7 @@ DWORD WINAPI gdi_render_main(void) fpsl_init(); - DWORD timeout = g_config.minfps > 0 ? g_config.minfps_tick_len : INFINITE; + DWORD timeout = g_config.minfps > 0 ? g_ddraw->minfps_tick_len : INFINITE; while (g_ddraw->render.run && (g_config.minfps < 0 || WaitForSingleObject(g_ddraw->render.sem, timeout) != WAIT_FAILED)) diff --git a/src/render_ogl.c b/src/render_ogl.c index 7170346..cc87e92 100644 --- a/src/render_ogl.c +++ b/src/render_ogl.c @@ -662,7 +662,7 @@ static void ogl_render() glEnable(GL_TEXTURE_2D); } - DWORD timeout = g_config.minfps > 0 ? g_config.minfps_tick_len : INFINITE; + DWORD timeout = g_config.minfps > 0 ? g_ddraw->minfps_tick_len : INFINITE; while (g_ogl.use_opengl && g_ddraw->render.run && (g_config.minfps < 0 || WaitForSingleObject(g_ddraw->render.sem, timeout) != WAIT_FAILED))