1
0
mirror of https://github.com/FunkyFr3sh/cnc-ddraw.git synced 2025-03-15 06:04:49 +01:00

Merge pull request #289 from egornovivan/master

Added support for subdir and sync of dll and ini names
This commit is contained in:
FunkyFr3sh 2024-02-16 21:05:30 +01:00 committed by GitHub
commit fcfbd9ef7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 4 deletions

View File

@ -13,8 +13,11 @@ typedef struct CNCDDRAWCONFIG
int upscaled_state;
char ini_path[MAX_PATH];
char game_path[MAX_PATH];
char dll_path[MAX_PATH];
char process_file_name[MAX_PATH];
char dll_file_name[MAX_PATH];
char process_file_ext[MAX_PATH];
char dll_file_ext[MAX_PATH];
INIFILE ini;
BOOL is_wine;

View File

@ -1095,11 +1095,29 @@ static void cfg_init()
}
}
/* get dll filename and directory */
if (GetModuleFileNameA(g_ddraw_module, g_config.dll_path, sizeof(g_config.dll_path) - 1) > 0)
{
_splitpath(g_config.dll_path, NULL, NULL, g_config.dll_file_name, g_config.dll_file_ext);
int len = strlen(g_config.dll_path) - strlen(g_config.dll_file_name) - strlen(g_config.dll_file_ext);
char* end = strstr(g_config.dll_path + len, g_config.dll_file_name);
if (end)
{
*end = 0;
}
else
{
g_config.dll_path[0] = 0;
}
}
if (!GetEnvironmentVariableA("CNC_DDRAW_CONFIG_FILE", g_config.ini_path, sizeof(g_config.ini_path) - 1))
{
if (strlen(g_config.game_path) > 0)
if (strlen(g_config.dll_path) > 0 && strlen(g_config.dll_file_name) > 0)
{
_snprintf(g_config.ini_path, sizeof(g_config.ini_path) - 1, "%sddraw.ini", g_config.game_path);
_snprintf(g_config.ini_path, sizeof(g_config.ini_path) - 1, "%s%s.ini", g_config.dll_path, g_config.dll_file_name);
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
{
@ -1108,7 +1126,7 @@ static void cfg_init()
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
{
strncpy(g_config.ini_path, ".\\ddraw.ini", sizeof(g_config.ini_path) - 1);
_snprintf(g_config.ini_path, sizeof(g_config.ini_path) - 1, "%s%s.ini", g_config.dll_path, g_config.dll_file_name);
}
}
else

View File

@ -160,7 +160,7 @@ static void ogl_build_programs()
if (GetFileAttributes(shader_path) == INVALID_FILE_ATTRIBUTES)
{
_snprintf(shader_path, sizeof(shader_path) - 1, "%s%s", g_config.game_path, g_config.shader);
_snprintf(shader_path, sizeof(shader_path) - 1, "%s%s", g_config.dll_path, g_config.shader);
}
/* detect common upscaling shaders and disable them if no upscaling is required */