mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-25 01:57:47 +01:00
specify full path to ddraw.ini in case of bad working dir
This commit is contained in:
parent
0997f514c4
commit
c21123b606
@ -12,6 +12,7 @@ typedef struct CNCDDRAWCONFIG
|
|||||||
char ini_path[MAX_PATH];
|
char ini_path[MAX_PATH];
|
||||||
char game_path[MAX_PATH];
|
char game_path[MAX_PATH];
|
||||||
char process_file_name[MAX_PATH];
|
char process_file_name[MAX_PATH];
|
||||||
|
char process_file_ext[MAX_PATH];
|
||||||
int save_settings;
|
int save_settings;
|
||||||
|
|
||||||
} CNCDDRAWCONFIG;
|
} CNCDDRAWCONFIG;
|
||||||
|
13
src/config.c
13
src/config.c
@ -1047,9 +1047,10 @@ static void cfg_init()
|
|||||||
/* get process filename and directory */
|
/* get process filename and directory */
|
||||||
if (GetModuleFileNameA(NULL, g_config.game_path, sizeof(g_config.game_path) - 1) > 0)
|
if (GetModuleFileNameA(NULL, g_config.game_path, sizeof(g_config.game_path) - 1) > 0)
|
||||||
{
|
{
|
||||||
_splitpath(g_config.game_path, NULL, NULL, g_config.process_file_name, NULL);
|
_splitpath(g_config.game_path, NULL, NULL, g_config.process_file_name, g_config.process_file_ext);
|
||||||
|
|
||||||
char* end = strstr(g_config.game_path, g_config.process_file_name);
|
int len = strlen(g_config.game_path) - strlen(g_config.process_file_name) - strlen(g_config.process_file_ext);
|
||||||
|
char* end = strstr(g_config.game_path + len, g_config.process_file_name);
|
||||||
|
|
||||||
if (end)
|
if (end)
|
||||||
{
|
{
|
||||||
@ -1066,6 +1067,14 @@ static void cfg_init()
|
|||||||
|
|
||||||
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
|
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
|
||||||
cfg_create_ini();
|
cfg_create_ini();
|
||||||
|
|
||||||
|
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
{
|
||||||
|
_snprintf(g_config.ini_path, sizeof(g_config.ini_path) - 1, "%sddraw.ini", g_config.game_path);
|
||||||
|
|
||||||
|
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
|
||||||
|
cfg_create_ini();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string, DWORD out_size)
|
DWORD cfg_get_string(LPCSTR key, LPCSTR default_value, LPSTR out_string, DWORD out_size)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user