static void load_inifile(dictionary * d) { const char *reportdir = reportpath(); const char *datadir = datapath(); const char *basedir = basepath(); const char *str; assert(d); str = iniparser_getstring(d, "eressea:base", basedir); if (str != basedir) { set_basepath(str); } str = iniparser_getstring(d, "eressea:report", reportdir); if (str != reportdir) { set_reportpath(str); } str = iniparser_getstring(d, "eressea:data", datadir); if (str != datadir) { set_datapath(str); } lomem = iniparser_getint(d, "eressea:lomem", lomem) ? 1 : 0; str = iniparser_getstring(d, "eressea:encoding", NULL); if (str && (_strcmpl(str, "utf8") == 0 || _strcmpl(str, "utf-8") == 0)) { enc_gamedata = ENCODING_UTF8; } verbosity = iniparser_getint(d, "eressea:verbose", 2); battledebug = iniparser_getint(d, "eressea:debug", battledebug) ? 1 : 0; str = iniparser_getstring(d, "eressea:locales", "de,en"); make_locales(str); if (global.inifile) iniparser_freedict(global.inifile); global.inifile = d; }
static dictionary *parse_config(const char *filename) { dictionary *d; const char *str, *cfgpath = config_get("config.path"); if (cfgpath) { char path[PATH_MAX]; path_join(cfgpath, filename, path, sizeof(path)); log_debug("reading from configuration file %s\n", path); d = iniparser_load(path); } else { log_debug("reading from configuration file %s\n", filename); d = iniparser_load(filename); } if (d) { config_set_from(d, valid_keys); load_inifile(); } str = config_get("game.locales"); make_locales(str ? str : "de,en"); return d; }