1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-25 18:17:47 +01:00
cnc-ddraw/src/config.c

606 lines
21 KiB
C
Raw Normal View History

#include <windows.h>
#include <stdio.h>
#include <d3d9.h>
#include "fps_limiter.h"
2020-10-13 09:20:52 +02:00
#include "config.h"
#include "dd.h"
#include "render_d3d9.h"
2020-10-13 09:20:52 +02:00
#include "render_gdi.h"
#include "render_ogl.h"
#include "hook.h"
2020-10-13 09:20:52 +02:00
#include "debug.h"
2020-10-13 11:29:52 +02:00
static BOOL cfg_get_bool(LPCSTR key, BOOL default_value);
static int cfg_get_int(LPCSTR key, int default_value);
static DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string, DWORD out_size);
2020-10-13 09:20:52 +02:00
static void cfg_create_ini();
2020-10-13 09:20:52 +02:00
cnc_ddraw_config g_config =
{ .window_rect = { .left = -32000, .top = -32000, .right = 0, .bottom = 0 }, .window_state = -1 };
void cfg_load()
{
//set up settings ini
char cwd[MAX_PATH];
char tmp[256];
GetCurrentDirectoryA(sizeof(cwd), cwd);
2020-10-13 09:20:52 +02:00
_snprintf(g_config.ini_path, sizeof(g_config.ini_path), "%s\\ddraw.ini", cwd);
2020-10-13 09:20:52 +02:00
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
cfg_create_ini();
//get process filename
2020-10-13 09:20:52 +02:00
char process_file_path[MAX_PATH] = { 0 };
GetModuleFileNameA(NULL, process_file_path, MAX_PATH);
_splitpath(process_file_path, NULL, NULL, g_config.process_file_name, NULL);
//load settings from ini
2020-10-13 09:20:52 +02:00
g_ddraw->windowed = cfg_get_bool("windowed", FALSE);
g_ddraw->border = cfg_get_bool("border", TRUE);
g_ddraw->boxing = cfg_get_bool("boxing", FALSE);
g_ddraw->maintas = cfg_get_bool("maintas", FALSE);
g_ddraw->adjmouse = cfg_get_bool("adjmouse", FALSE);
g_ddraw->devmode = cfg_get_bool("devmode", FALSE);
g_ddraw->vsync = cfg_get_bool("vsync", FALSE);
g_ddraw->noactivateapp = cfg_get_bool("noactivateapp", FALSE);
g_ddraw->vhack = cfg_get_bool("vhack", FALSE);
g_ddraw->accurate_timers = cfg_get_bool("accuratetimers", FALSE);
g_ddraw->resizable = cfg_get_bool("resizable", TRUE);
g_ddraw->nonexclusive = cfg_get_bool("nonexclusive", FALSE);
g_ddraw->fixchildwindows = cfg_get_bool("fixchildwindows", TRUE);
g_ddraw->d3d9linear = cfg_get_bool("d3d9linear", TRUE);
2021-05-04 22:49:22 +02:00
g_ddraw->backbuffer = cfg_get_bool("backbuffer", TRUE);
g_ddraw->passthrough = cfg_get_bool("passthrough", TRUE);
2020-10-13 09:20:52 +02:00
g_ddraw->sierrahack = cfg_get_bool("sierrahack", FALSE); // Sierra Caesar III, Pharaoh, and Zeus hack
g_config.window_rect.right = cfg_get_int("width", 0);
g_config.window_rect.bottom = cfg_get_int("height", 0);
g_config.window_rect.left = cfg_get_int("posX", -32000);
g_config.window_rect.top = cfg_get_int("posY", -32000);
g_config.save_settings = cfg_get_int("savesettings", 1);
2020-09-30 10:14:30 +02:00
2020-10-13 09:20:52 +02:00
g_hook_method = cfg_get_int("hook", 4);
2021-02-18 11:14:26 +01:00
g_ddraw->render.maxfps = cfg_get_int("maxfps", -1);
2020-10-18 02:40:45 +02:00
g_ddraw->render.minfps = cfg_get_int("minfps", 0);
2018-12-10 04:24:30 +01:00
2020-10-18 02:40:45 +02:00
if (g_ddraw->render.minfps > 1000)
{
g_ddraw->render.minfps = 1000;
}
if (g_ddraw->render.minfps > 0)
{
g_ddraw->render.minfps_tick_len = 1000.0f / g_ddraw->render.minfps;
}
2020-01-23 08:58:22 +01:00
2020-10-13 09:20:52 +02:00
if (g_ddraw->accurate_timers || g_ddraw->vsync)
g_fpsl.htimer = CreateWaitableTimer(NULL, TRUE, NULL);
2020-10-13 09:20:52 +02:00
//can't fully set it up here due to missing g_ddraw->mode.dmDisplayFrequency
2021-02-19 03:24:11 +01:00
g_ddraw->maxgameticks = cfg_get_int("maxgameticks", 0);
2020-10-13 11:29:52 +02:00
2021-02-19 03:24:11 +01:00
if (g_ddraw->maxgameticks > 0 && g_ddraw->maxgameticks <= 1000)
{
2020-10-13 09:20:52 +02:00
if (g_ddraw->accurate_timers)
g_ddraw->ticks_limiter.htimer = CreateWaitableTimer(NULL, TRUE, NULL);
2018-11-30 04:07:43 +01:00
2021-02-19 03:24:11 +01:00
float len = 1000.0f / g_ddraw->maxgameticks;
2020-10-13 09:20:52 +02:00
g_ddraw->ticks_limiter.tick_length_ns = len * 10000;
g_ddraw->ticks_limiter.tick_length = len + 0.5f;
}
2021-02-19 03:24:11 +01:00
if (g_ddraw->maxgameticks >= 0 || g_ddraw->maxgameticks == -2)
{
//always using 60 fps for flip...
2020-10-13 09:20:52 +02:00
if (g_ddraw->accurate_timers)
g_ddraw->flip_limiter.htimer = CreateWaitableTimer(NULL, TRUE, NULL);
2020-10-13 09:20:52 +02:00
float flip_len = 1000.0f / 60;
g_ddraw->flip_limiter.tick_length_ns = flip_len * 10000;
g_ddraw->flip_limiter.tick_length = flip_len + 0.5f;
}
2018-11-30 04:07:43 +01:00
2020-10-13 09:20:52 +02:00
if ((g_ddraw->fullscreen = cfg_get_bool("fullscreen", FALSE)))
2020-10-13 11:29:52 +02:00
{
2020-10-13 09:20:52 +02:00
g_config.window_rect.left = g_config.window_rect.top = -32000;
2020-10-13 11:29:52 +02:00
}
2020-10-13 09:20:52 +02:00
if (!(g_ddraw->handlemouse = cfg_get_bool("handlemouse", TRUE)))
2020-10-13 11:29:52 +02:00
{
2020-10-13 09:20:52 +02:00
g_ddraw->adjmouse = TRUE;
2020-10-13 11:29:52 +02:00
}
2020-10-13 09:20:52 +02:00
if (cfg_get_bool("singlecpu", TRUE))
{
SetProcessAffinityMask(GetCurrentProcess(), 1);
}
else
{
2020-10-13 09:20:52 +02:00
DWORD system_affinity;
DWORD proc_affinity;
HANDLE proc = GetCurrentProcess();
2020-10-13 21:58:04 +02:00
2020-10-13 09:20:52 +02:00
if (GetProcessAffinityMask(proc, &proc_affinity, &system_affinity))
SetProcessAffinityMask(proc, system_affinity);
}
2020-10-13 09:20:52 +02:00
g_ddraw->render.bpp = cfg_get_int("bpp", 0);
if (g_ddraw->render.bpp != 16 && g_ddraw->render.bpp != 24 && g_ddraw->render.bpp != 32)
2020-10-13 11:29:52 +02:00
{
2020-10-13 09:20:52 +02:00
g_ddraw->render.bpp = 0;
2020-10-13 11:29:52 +02:00
}
// to do: read .glslp config file instead of the shader and apply the correct settings
2020-10-13 09:20:52 +02:00
cfg_get_string("shader", "", g_ddraw->shader, sizeof(g_ddraw->shader));
2020-10-13 09:20:52 +02:00
cfg_get_string("renderer", "auto", tmp, sizeof(tmp));
dprintf(" Using %s renderer\n", tmp);
if (tolower(tmp[0]) == 's' || tolower(tmp[0]) == 'g') //gdi
{
2020-10-13 09:20:52 +02:00
g_ddraw->renderer = gdi_render_main;
}
else if (tolower(tmp[0]) == 'd') //direct3d9
{
2020-10-13 09:20:52 +02:00
g_ddraw->renderer = d3d9_render_main;
}
else if (tolower(tmp[0]) == 'o') //opengl
{
2020-10-13 09:20:52 +02:00
if (oglu_load_dll())
{
2020-10-13 09:20:52 +02:00
g_ddraw->renderer = ogl_render_main;
}
else
{
2020-10-13 09:20:52 +02:00
g_ddraw->show_driver_warning = TRUE;
g_ddraw->renderer = gdi_render_main;
}
}
else //auto
{
2020-10-13 09:20:52 +02:00
if (!g_ddraw->wine && d3d9_is_available())
{
2020-10-13 09:20:52 +02:00
g_ddraw->renderer = d3d9_render_main;
}
2020-10-13 09:20:52 +02:00
else if (oglu_load_dll())
{
2020-10-13 09:20:52 +02:00
g_ddraw->renderer = ogl_render_main;
}
else
{
2020-10-13 09:20:52 +02:00
g_ddraw->show_driver_warning = TRUE;
g_ddraw->renderer = gdi_render_main;
}
}
}
2020-10-13 09:20:52 +02:00
void cfg_save()
{
2020-10-13 09:20:52 +02:00
if (!g_config.save_settings)
2020-09-30 10:14:30 +02:00
return;
char buf[16];
2020-10-13 09:20:52 +02:00
char *section = g_config.save_settings == 1 ? "ddraw" : g_config.process_file_name;
2020-10-13 09:20:52 +02:00
if (g_config.window_rect.right)
2018-10-25 09:31:40 +02:00
{
2020-10-13 09:20:52 +02:00
sprintf(buf, "%ld", g_config.window_rect.right);
WritePrivateProfileString(section, "width", buf, g_config.ini_path);
2018-10-27 16:44:09 +02:00
}
2020-10-13 09:20:52 +02:00
if (g_config.window_rect.bottom)
2018-10-27 16:44:09 +02:00
{
2020-10-13 09:20:52 +02:00
sprintf(buf, "%ld", g_config.window_rect.bottom);
WritePrivateProfileString(section, "height", buf, g_config.ini_path);
2018-10-27 16:44:09 +02:00
}
2020-10-13 09:20:52 +02:00
if (g_config.window_rect.left != -32000)
2018-10-27 16:44:09 +02:00
{
2020-10-13 09:20:52 +02:00
sprintf(buf, "%ld", g_config.window_rect.left);
WritePrivateProfileString(section, "posX", buf, g_config.ini_path);
2018-10-25 09:31:40 +02:00
}
2020-10-13 09:20:52 +02:00
if (g_config.window_rect.top != -32000)
2018-10-25 09:31:40 +02:00
{
2020-10-13 09:20:52 +02:00
sprintf(buf, "%ld", g_config.window_rect.top);
WritePrivateProfileString(section, "posY", buf, g_config.ini_path);
2018-11-07 23:28:19 +01:00
}
2020-10-13 09:20:52 +02:00
if (g_config.window_state != -1)
2018-11-07 23:28:19 +01:00
{
2020-10-13 09:20:52 +02:00
WritePrivateProfileString(section, "windowed", g_config.window_state ? "true" : "false", g_config.ini_path);
2018-10-25 09:31:40 +02:00
}
}
2020-10-13 09:20:52 +02:00
static void cfg_create_ini()
{
2020-10-13 09:20:52 +02:00
FILE *fh = fopen(g_config.ini_path, "w");
if (fh)
{
fputs(
"; cnc-ddraw - https://github.com/CnCNet/cnc-ddraw - https://cncnet.org\n"
"\n"
"[ddraw]\n"
"; ### Optional settings ###\n"
"; Use the following settings to adjust the look and feel to your liking\n"
"\n"
"\n"
"; Stretch to custom resolution, 0 = defaults to the size game requests\n"
"width=0\n"
"height=0\n"
"\n"
"; Override the width/height settings shown above and always stretch to fullscreen\n"
"; Note: Can be combined with 'windowed=true' to get windowed-fullscreen aka borderless mode\n"
"fullscreen=false\n"
"\n"
"; Run in windowed mode rather than going fullscreen\n"
"windowed=false\n"
"\n"
"; Maintain aspect ratio - (Requires 'handlemouse=true')\n"
"maintas=false\n"
"\n"
"; Windowboxing / Integer Scaling - (Requires 'handlemouse=true')\n"
"boxing=false\n"
"\n"
"; Real rendering rate, -1 = screen rate, 0 = unlimited, n = cap\n"
"; Note: Does not have an impact on the game speed, to limit your game speed use 'maxgameticks='\n"
2021-02-18 11:14:26 +01:00
"maxfps=-1\n"
"\n"
"; Vertical synchronization, enable if you get tearing - (Requires 'renderer=auto/opengl/direct3d9')\n"
2020-10-06 21:08:29 +02:00
"; Note: vsync=true can fix tearing but it will cause input lag\n"
"vsync=false\n"
"\n"
"; Automatic mouse sensitivity scaling - (Requires 'handlemouse=true')\n"
"; Note: Only works if stretching is enabled. Sensitivity will be adjusted according to the size of the window\n"
"adjmouse=false\n"
"\n"
"; Preliminary libretro shader support - (Requires 'renderer=opengl') https://github.com/libretro/glsl-shaders\n"
2020-10-06 21:08:29 +02:00
"; 2x scaling example: https://imgur.com/a/kxsM1oY - 4x scaling example: https://imgur.com/a/wjrhpFV\n"
2021-01-17 22:45:44 +01:00
"shader=Shaders\\interpolation\\bilinear.glsl\n"
"\n"
"; Window position, -32000 = center to screen\n"
"posX=-32000\n"
"posY=-32000\n"
"\n"
"; Renderer, possible values: auto, opengl, gdi, direct3d9 (auto = try direct3d9/opengl, fallback = gdi)\n"
"renderer=auto\n"
"\n"
"; Developer mode (don't lock the cursor)\n"
"devmode=false\n"
"\n"
"; Show window borders in windowed mode\n"
"border=true\n"
"\n"
2020-09-30 10:14:30 +02:00
"; Save window position/size/state on game exit and restore it automatically on next game start\n"
"; Possible values: 0 = disabled, 1 = save to global 'ddraw' section, 2 = save to game specific section\n"
"savesettings=1\n"
2020-09-30 10:14:30 +02:00
"\n"
"; Should the window be resizeable by the user in windowed mode?\n"
"resizeable=true\n"
"\n"
"; Enable C&C video resize hack - Stretches C&C cutscenes to fullscreen\n"
"vhack=false\n"
"\n"
"; Enable linear (D3DTEXF_LINEAR) upscaling filter for the direct3d9 renderer (16 bit color depth games only)\n"
"d3d9linear=true\n"
"\n"
"\n"
"\n"
"; ### Compatibility settings ###\n"
"; Use the following settings in case there are any issues with the game\n"
"\n"
"\n"
"; Hide WM_ACTIVATEAPP and WM_NCACTIVATE messages to prevent problems on alt+tab\n"
"noactivateapp=false\n"
"\n"
2021-02-19 03:24:11 +01:00
"; Max game ticks per second, possible values: -1 = disabled, -2 = refresh rate, 0 = emulate 60hz vblank, 1-1000 = custom game speed\n"
"; Note: Can be used to slow down a too fast running game, fix flickering or too fast animations\n"
2020-10-06 21:08:29 +02:00
"; Note: Usually one of the following values will work: 60 / 30 / 25 / 20 / 15 (lower value = slower game speed)\n"
"maxgameticks=0\n"
"\n"
"; Gives cnc-ddraw full control over the mouse cursor (required for adjmouse/boxing/maintas)\n"
2020-10-06 21:08:29 +02:00
"; Note: Set this to 'false' if your cursor becomes invisible at some places in the game\n"
"handlemouse=true\n"
"\n"
"; Windows API Hooking, Possible values: 0 = disabled, 1 = IAT Hooking, 2 = Microsoft Detours, 3 = IAT+Detours Hooking (All Modules), 4 = IAT Hooking (All Modules)\n"
2020-10-18 02:40:45 +02:00
"; Note: Change this value if windowed mode or upscaling isn't working properly\n"
"; Note: 'hook=2' will usually work for problematic games, but 'hook=2' must be combined with renderer=gdi\n"
2020-09-23 04:47:13 +02:00
"hook=4\n"
2019-03-20 05:07:28 +01:00
"\n"
2020-10-18 02:40:45 +02:00
"; Force minimum FPS, possible values: 0 = disabled, -1 = use 'maxfps=' value, 1-1000 = custom FPS\n"
"; Note: Set this to a low value such as 5 or 10 if some parts of the game are not being displayed (e.g. menus or loading screens)\n"
"minfps=0\n"
2020-01-23 08:58:22 +01:00
"\n"
"; Disable fullscreen-exclusive mode for the direct3d9/opengl renderers\n"
"; Note: Can be used in case some GUI elements like buttons/textboxes/videos/etc.. are invisible\n"
"nonexclusive=false\n"
"\n"
2020-09-27 05:13:15 +02:00
"; Force CPU0 affinity, avoids crashes/freezing, *might* have a performance impact\n"
"singlecpu=true\n"
"\n"
"\n"
"\n"
"; ### Game specific settings ###\n"
"; The following settings override all settings shown above, section name = executable name\n"
"\n"
"\n"
2020-09-27 10:23:16 +02:00
"; Command & Conquer: Red Alert - CnCNet\n"
"[ra95-spawn]\n"
"maxfps=125\n"
"\n"
"; Command & Conquer Gold - CnCNet\n"
"[cnc95]\n"
"maxfps=125\n"
"\n"
"; Carmageddon\n"
"[CARMA95]\n"
2018-10-31 16:37:27 +01:00
"renderer=opengl\n"
"noactivateapp=true\n"
2020-09-23 04:29:02 +02:00
"\n"
"; Carmageddon\n"
"[CARM95]\n"
"renderer=opengl\n"
"noactivateapp=true\n"
"\n"
"; Command & Conquer Gold\n"
"[C&C95]\n"
"maxgameticks=120\n"
2020-01-23 08:58:22 +01:00
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
"\n"
2018-11-14 09:12:56 +01:00
"; Command & Conquer: Red Alert\n"
"[ra95]\n"
"maxgameticks=120\n"
2020-01-23 08:58:22 +01:00
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2020-01-23 08:58:22 +01:00
"\n"
"; Command & Conquer: Red Alert\n"
"[ra95p]\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2018-11-14 09:12:56 +01:00
"\n"
"; Age of Empires\n"
"[empires]\n"
"handlemouse=false\n"
"\n"
"; Age of Empires: The Rise of Rome\n"
"[empiresx]\n"
"handlemouse=false\n"
"\n"
"; Age of Empires II\n"
"[EMPIRES2]\n"
"handlemouse=false\n"
"\n"
"; Age of Empires II: The Conquerors\n"
"[age2_x1]\n"
"handlemouse=false\n"
"\n"
"; Outlaws\n"
2018-10-30 19:38:32 +01:00
"[olwin]\n"
"noactivateapp=true\n"
"maxgameticks=60\n"
2019-04-06 06:20:19 +02:00
"handlemouse=false\n"
"renderer=gdi\n"
2018-10-30 19:38:32 +01:00
"\n"
"; Dark Reign: The Future of War\n"
2018-10-31 00:33:21 +01:00
"[DKReign]\n"
"maxgameticks=60\n"
2018-10-31 00:33:21 +01:00
"\n"
"; Star Wars: Galactic Battlegrounds\n"
"[battlegrounds]\n"
"handlemouse=false\n"
"\n"
"; Star Wars: Galactic Battlegrounds: Clone Campaigns\n"
"[battlegrounds_x1]\n"
"handlemouse=false\n"
"\n"
"; Carmageddon 2\n"
2018-11-02 02:21:16 +01:00
"[Carma2_SW]\n"
"renderer=opengl\n"
"noactivateapp=true\n"
"\n"
"; Atomic Bomberman\n"
"[BM]\n"
"maxgameticks=60\n"
"\n"
"; Command & Conquer: Tiberian Sun / Command & Conquer: Red Alert 2\n"
2018-11-15 10:47:18 +01:00
"[game]\n"
"checkfile=.\\blowfish.dll\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2018-11-15 10:47:18 +01:00
"\n"
2019-01-28 20:25:45 +01:00
"; Command & Conquer: Tiberian Sun Demo\n"
"[SUN]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2019-01-28 20:25:45 +01:00
"\n"
"; Command & Conquer: Tiberian Sun - CnCNet\n"
2018-11-15 10:47:18 +01:00
"[ts-spawn]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2018-11-15 10:47:18 +01:00
"\n"
"; Command & Conquer: Red Alert 2 - XWIS\n"
"[ra2]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
"\n"
"; Command & Conquer: Red Alert 2 - XWIS\n"
"[Red Alert 2]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
"\n"
2018-11-15 10:47:18 +01:00
"; Command & Conquer: Red Alert 2: Yuri's Revenge\n"
"[gamemd]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2018-11-15 10:47:18 +01:00
"\n"
2020-01-22 07:23:27 +01:00
"; Command & Conquer: Red Alert 2: Yuri's Revenge - ?ModExe?\n"
"[ra2md]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2020-01-22 07:23:27 +01:00
"\n"
"; Command & Conquer: Red Alert 2: Yuri's Revenge - CnCNet\n"
2018-11-15 10:47:18 +01:00
"[gamemd-spawn]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
2018-11-15 10:47:18 +01:00
"\n"
"; Command & Conquer: Red Alert 2: Yuri's Revenge - XWIS\n"
"[Yuri's Revenge]\n"
"noactivateapp=true\n"
"handlemouse=false\n"
"maxfps=60\n"
2020-10-18 02:40:45 +02:00
"minfps=-1\n"
"\n"
2020-10-02 22:33:07 +02:00
"; Twisted Metal\n"
"[TWISTED]\n"
2020-10-06 20:48:43 +02:00
"renderer=opengl\n"
"nonexclusive=true\n"
2020-10-04 18:12:34 +02:00
"maxgameticks=25\n"
2020-10-18 02:40:45 +02:00
"minfps=5\n"
2020-10-02 22:33:07 +02:00
"\n"
"; Twisted Metal 2\n"
"[Tm2]\n"
"renderer=opengl\n"
"nonexclusive=true\n"
"maxgameticks=60\n"
"handlemouse=false\n"
"fixchildwindows=false\n"
"\n"
"; Caesar III\n"
"[c3]\n"
"handlemouse=false\n"
"sierrahack=true\n"
"\n"
"; Pharaoh\n"
"[Pharaoh]\n"
"handlemouse=false\n"
"sierrahack=true\n"
"\n"
"; Master of Olympus - Zeus\n"
"[Zeus]\n"
"handlemouse=false\n"
"sierrahack=true\n"
"renderer=gdi\n"
"hook=2\n"
"\n"
2020-10-15 08:09:13 +02:00
"; Dungeon Keeper 2\n"
"[DKII]\n"
"maxgameticks=60\n"
"noactivateapp=true\n"
"passthrough=false\n"
2020-10-15 08:09:13 +02:00
"\n"
2020-10-22 21:40:46 +02:00
"; Chris Sawyer's Locomotion\n"
"[LOCO]\n"
"handlemouse=false\n"
"\n"
2020-10-22 22:20:19 +02:00
"; Age of Wonders\n"
"[AoWSM]\n"
"windowed=true\n"
"fullscreen=false\n"
"renderer=gdi\n"
"hook=2\n"
"\n"
"; Age of Wonders 2\n"
"[AoW2]\n"
"windowed=true\n"
"fullscreen=false\n"
"renderer=gdi\n"
"hook=2\n"
"\n"
2020-10-23 18:06:35 +02:00
"; Stronghold Crusader HD\n"
"[Stronghold Crusader]\n"
"handlemouse=false\n"
"\n"
"; Stronghold Crusader Extreme HD\n"
"[Stronghold_Crusader_Extreme]\n"
"handlemouse=false\n"
"\n"
2021-04-02 00:24:22 +02:00
"; Cultures 2\n"
"[Cultures2]\n"
"handlemouse=false\n"
"\n"
"; Cultures 2 MP\n"
"[Cultures2MP]\n"
"handlemouse=false\n"
"\n"
"; Blade & Sword\n"
"[comeon]\n"
"renderer=opengl\n"
"nonexclusive=true\n"
"\n"
2021-05-04 22:49:22 +02:00
"; Tzar: The Burden of the Crown\n"
"; Note: Must set 'DIRECTXDEVICE=0' in 'Tzar.ini'\n"
"[Tzar]\n"
"handlemouse=false\n"
"\n"
2021-05-05 17:47:35 +02:00
"; Jagged Alliance 2\n"
"[ja2]\n"
"hook=0\n"
"\n"
, fh);
fclose(fh);
}
}
2020-10-13 11:29:52 +02:00
static DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string, DWORD out_size)
{
2020-10-13 09:20:52 +02:00
DWORD s = GetPrivateProfileStringA(
2020-10-13 11:29:52 +02:00
g_config.process_file_name, key, "", out_string, out_size, g_config.ini_path);
2020-10-13 09:20:52 +02:00
if (s > 0)
{
char buf[MAX_PATH] = { 0 };
2020-10-13 09:20:52 +02:00
if (GetPrivateProfileStringA(
g_config.process_file_name, "checkfile", "", buf, sizeof(buf), g_config.ini_path) > 0)
{
if (GetFileAttributes(buf) != INVALID_FILE_ATTRIBUTES)
return s;
}
else
return s;
}
2020-10-13 11:29:52 +02:00
return GetPrivateProfileStringA("ddraw", key, default_value, out_string, out_size, g_config.ini_path);
}
2020-10-13 11:29:52 +02:00
static BOOL cfg_get_bool(LPCSTR key, BOOL default_value)
{
2019-01-28 21:11:34 +01:00
char value[8];
2020-10-13 11:29:52 +02:00
cfg_get_string(key, default_value ? "Yes" : "No", value, sizeof(value));
2019-01-28 21:11:34 +01:00
return (_stricmp(value, "yes") == 0 || _stricmp(value, "true") == 0 || _stricmp(value, "1") == 0);
}
2020-10-13 11:29:52 +02:00
static int cfg_get_int(LPCSTR key, int default_value)
{
2020-10-13 09:20:52 +02:00
char def_value[16];
2020-10-13 11:29:52 +02:00
_snprintf(def_value, sizeof(def_value), "%d", default_value);
2019-01-28 21:11:34 +01:00
char value[16];
2020-10-13 09:20:52 +02:00
cfg_get_string(key, def_value, value, sizeof(value));
2019-01-28 21:11:34 +01:00
return atoi(value);
}