load inifile in main, it is only used by the server.

this should fix the broken CI build.
This commit is contained in:
Enno Rehling 2014-12-09 06:01:10 +01:00
parent b551edbdb3
commit 3428f40f81
3 changed files with 41 additions and 40 deletions

View File

@ -62,7 +62,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <util/crmessage.h> #include <util/crmessage.h>
#include <util/event.h> #include <util/event.h>
#include <util/language.h> #include <util/language.h>
#include <util/filereader.h>
#include <util/functions.h> #include <util/functions.h>
#include <util/log.h> #include <util/log.h>
#include <util/lists.h> #include <util/lists.h>
@ -2332,41 +2331,3 @@ int game_id(void) {
return get_param_int(global.parameters, "game.id", 0); return get_param_int(global.parameters, "game.id", 0);
} }
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_free(global.inifile);
global.inifile = d;
}

View File

@ -301,7 +301,6 @@ extern "C" {
const char *basepath(void); const char *basepath(void);
void set_basepath(const char *); void set_basepath(const char *);
void load_inifile(struct _dictionary_ *d);
const char *reportpath(void); const char *reportpath(void);
void set_reportpath(const char *); void set_reportpath(const char *);

View File

@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/config.h> #include <kernel/config.h>
#include <kernel/save.h> #include <kernel/save.h>
#include <kernel/version.h> #include <kernel/version.h>
#include <util/filereader.h>
#include <util/language.h>
#include "eressea.h" #include "eressea.h"
#ifdef USE_CURSES #ifdef USE_CURSES
#include "gmtool.h" #include "gmtool.h"
@ -43,6 +45,45 @@ static const char *luafile = 0;
static const char *inifile = "eressea.ini"; static const char *inifile = "eressea.ini";
static int memdebug = 0; static int memdebug = 0;
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_free(global.inifile);
global.inifile = d;
}
static void parse_config(const char *filename) static void parse_config(const char *filename)
{ {
dictionary *d = iniparser_new(filename); dictionary *d = iniparser_new(filename);