mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
Let cnc-ddraw create a new ddraw.ini if it doesn't exist
This commit is contained in:
parent
cb7fde77ea
commit
15cee173fc
@ -541,6 +541,31 @@ void __fastcall TConfigForm::CompatibilityBtnClick(TObject *Sender)
|
||||
|
||||
void __fastcall TConfigForm::FormCreate(TObject *Sender)
|
||||
{
|
||||
/* Let cnc-ddraw create a new ddraw.ini if it doesn't exist */
|
||||
if (!FileExists(".\\ddraw.ini")) {
|
||||
|
||||
SetEnvironmentVariableW(L"cnc_ddraw_config_init", L"1");
|
||||
|
||||
HMODULE ddraw = LoadLibraryW(L".\\ddraw.dll");
|
||||
|
||||
if (ddraw) {
|
||||
|
||||
void (WINAPI* dd_create)(void*, void**, void*);
|
||||
|
||||
dd_create =
|
||||
(void (WINAPI*)(void*, void**, void*))
|
||||
GetProcAddress(ddraw, "DirectDrawCreate");
|
||||
|
||||
if (dd_create) {
|
||||
|
||||
void *buf;
|
||||
dd_create(NULL, &buf, NULL);
|
||||
}
|
||||
|
||||
FreeLibrary(ddraw);
|
||||
}
|
||||
}
|
||||
|
||||
auto *ini = new TIniFile(".\\ddraw.ini");
|
||||
|
||||
ApplyTranslation(ini);
|
||||
@ -860,6 +885,7 @@ void TConfigForm::SaveSettings()
|
||||
|
||||
void __fastcall TConfigForm::FormActivate(TObject *Sender)
|
||||
{
|
||||
/* Detect wine (Linux/macOS) and create the needed dll override */
|
||||
if (!GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "wine_get_version"))
|
||||
return;
|
||||
|
||||
|
@ -20,6 +20,7 @@ typedef struct CNCDDRAWCONFIG
|
||||
|
||||
extern CNCDDRAWCONFIG g_config;
|
||||
|
||||
void cfg_init();
|
||||
void cfg_load();
|
||||
void cfg_save();
|
||||
|
||||
|
@ -901,10 +901,6 @@ static void cfg_create_ini()
|
||||
"adjmouse=true\n"
|
||||
"fixchilds=1\n"
|
||||
"\n"
|
||||
"; Septerra Core\n"
|
||||
"[septerra]\n"
|
||||
"hook=2\n"
|
||||
"\n"
|
||||
"; Sim Copter\n"
|
||||
"[SimCopter]\n"
|
||||
"renderer=opengl\n"
|
||||
@ -1058,7 +1054,7 @@ static void cfg_create_ini()
|
||||
}
|
||||
}
|
||||
|
||||
static void cfg_init()
|
||||
void cfg_init()
|
||||
{
|
||||
/* get process filename and directory */
|
||||
if (GetModuleFileNameA(NULL, g_config.game_path, sizeof(g_config.game_path) - 1) > 0)
|
||||
|
@ -22,6 +22,9 @@ HMODULE g_ddraw_module;
|
||||
|
||||
BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
if (GetEnvironmentVariableW(L"cnc_ddraw_config_init", NULL, 0))
|
||||
return TRUE;
|
||||
|
||||
switch (dwReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
|
Loading…
x
Reference in New Issue
Block a user