diff --git a/src/bindings.c b/src/bindings.c index 048353c01..0719c3624 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -851,7 +851,7 @@ static void parse_inifile(lua_State * L, const dictionary * d, const char *secti lua_pushstring(L, "reportpath"); lua_pushstring(L, reportpath()); lua_rawset(L, -3); - arg = config_get("config.rules"); + arg = config_get("game.rules"); if (arg) { lua_pushstring(L, "rules"); lua_pushstring(L, arg); diff --git a/src/main.c b/src/main.c index 2ab33007f..5ab51a682 100644 --- a/src/main.c +++ b/src/main.c @@ -74,6 +74,7 @@ static const char * valid_keys[] = { "game.locale", "game.verbose", "game.report", + "game.rules", "game.memcheck", "game.email", "game.mailcmd", @@ -89,25 +90,30 @@ static const char * valid_keys[] = { NULL }; +static dictionary * load_config(const char *path) +{ + log_debug("reading from configuration file %s\n", path); + return iniparser_load(path); +} + static dictionary *parse_config(const char *filename) { - dictionary *d; - const char *str, *cfgpath = config_get("config.path"); + char path[PATH_MAX]; + dictionary *d = NULL; + const char *str; - 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); + d = load_config(filename); + if (!d) { + path_join(basepath(), filename, path, sizeof(path)); + d = load_config(path); } if (d) { config_set_from(d, valid_keys); load_inifile(); } + else { + log_fatal("could not find eressea.ini"); + } str = config_get("game.locales"); make_locales(str ? str : "de,en"); return d; @@ -205,7 +211,7 @@ static int parse_args(int argc, char **argv) break; case 'C': i = get_arg(argc, argv, 2, i, &arg, 0); - config_set("config.path", arg); + inifile = arg; break; case 'r': i = get_arg(argc, argv, 2, i, &arg, 0); diff --git a/tests/eressea.ini b/tests/eressea.ini index 3eb8e6189..bdd9094d2 100644 --- a/tests/eressea.ini +++ b/tests/eressea.ini @@ -1,11 +1,11 @@ [game] +rules = e2 name = Eressea id = 2 email = eressea-server@kn-bremen.de -verbose = 0 -locales = de,en +verbose = 0 +locales = de,en [lua] -install = .. -maxnmrs = 20 -rules = e2 +install = .. +maxnmrs = 20