mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-24 17:49:52 +01:00
move ini creating to cfg_init
This commit is contained in:
parent
8702ffe44a
commit
447e0ca2c9
14
src/config.c
14
src/config.c
@ -10,7 +10,7 @@
|
|||||||
#include "hook.h"
|
#include "hook.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
static void cfg_init_paths();
|
static void cfg_init();
|
||||||
static void cfg_create_ini();
|
static void cfg_create_ini();
|
||||||
|
|
||||||
CNCDDRAWCONFIG g_config =
|
CNCDDRAWCONFIG g_config =
|
||||||
@ -20,10 +20,7 @@ void cfg_load()
|
|||||||
{
|
{
|
||||||
char tmp[256];
|
char tmp[256];
|
||||||
|
|
||||||
cfg_init_paths();
|
cfg_init();
|
||||||
|
|
||||||
if (GetFileAttributes(g_config.ini_path) == INVALID_FILE_ATTRIBUTES)
|
|
||||||
cfg_create_ini();
|
|
||||||
|
|
||||||
/* load settings from ini */
|
/* load settings from ini */
|
||||||
g_ddraw->windowed = cfg_get_bool("windowed", FALSE);
|
g_ddraw->windowed = cfg_get_bool("windowed", FALSE);
|
||||||
@ -930,7 +927,7 @@ static void cfg_create_ini()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cfg_init_paths()
|
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)
|
||||||
@ -951,12 +948,15 @@ static void cfg_init_paths()
|
|||||||
|
|
||||||
/* set up settings ini */
|
/* set up settings ini */
|
||||||
strncpy(g_config.ini_path, ".\\ddraw.ini", sizeof(g_config.ini_path) - 1);
|
strncpy(g_config.ini_path, ".\\ddraw.ini", sizeof(g_config.ini_path) - 1);
|
||||||
|
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
if (!g_config.ini_path[0])
|
if (!g_config.ini_path[0])
|
||||||
cfg_init_paths();
|
cfg_init();
|
||||||
|
|
||||||
DWORD s = GetPrivateProfileStringA(
|
DWORD s = GetPrivateProfileStringA(
|
||||||
g_config.process_file_name, key, "", out_string, out_size, g_config.ini_path);
|
g_config.process_file_name, key, "", out_string, out_size, g_config.ini_path);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user