setting the rules directory with -r (overrides config.rules from eressea.ini)

This commit is contained in:
Enno Rehling 2014-07-23 15:44:57 +02:00
parent 30e9565ae6
commit 44327d91f6
4 changed files with 39 additions and 30 deletions

View File

@ -34,7 +34,7 @@ function run_turn()
end end
orderfile = orderfile or config.basepath .. '/orders.' .. turn orderfile = orderfile or config.basepath .. '/orders.' .. turn
print("executing turn " .. get_turn() .. " with " .. orderfile) print("executing turn " .. get_turn() .. " with " .. orderfile .. " with rules=" .. config.rules)
local result = process(orderfile) local result = process(orderfile)
if result==0 then if result==0 then
dbupdate() dbupdate()

View File

@ -1026,31 +1026,40 @@ static int tolua_report_unit(lua_State * L)
static void parse_inifile(lua_State * L, dictionary * d, const char *section) static void parse_inifile(lua_State * L, dictionary * d, const char *section)
{ {
int i; int i;
size_t len = strlen(section); const char *arg;
for (i = 0; d && i != d->n; ++i) { size_t len = strlen(section);
const char *key = d->key[i];
if (strncmp(section, key, len) == 0 && key[len] == ':') {
const char *str_value = d->val[i];
char *endp;
double num_value = strtod(str_value, &endp);
lua_pushstring(L, key + len + 1);
if (*endp) {
tolua_pushstring(L, str_value);
} else {
tolua_pushnumber(L, num_value);
}
lua_rawset(L, -3);
}
}
/* special case */ for (i = 0; d && i != d->n; ++i) {
lua_pushstring(L, "basepath"); const char *key = d->key[i];
lua_pushstring(L, basepath()); if (strncmp(section, key, len) == 0 && key[len] == ':') {
lua_rawset(L, -3); const char *str_value = d->val[i];
lua_pushstring(L, "reportpath"); char *endp;
lua_pushstring(L, reportpath()); double num_value = strtod(str_value, &endp);
lua_rawset(L, -3); lua_pushstring(L, key + len + 1);
if (*endp) {
tolua_pushstring(L, str_value);
}
else {
tolua_pushnumber(L, num_value);
}
lua_rawset(L, -3);
}
}
/* special case */
lua_pushstring(L, "basepath");
lua_pushstring(L, basepath());
lua_rawset(L, -3);
lua_pushstring(L, "reportpath");
lua_pushstring(L, reportpath());
lua_rawset(L, -3);
arg = get_param(global.parameters, "config.rules");
if (arg) {
lua_pushstring(L, "rules");
lua_pushstring(L, arg);
lua_rawset(L, -3);
}
} }
int tolua_bindings_open(lua_State * L) int tolua_bindings_open(lua_State * L)

View File

@ -121,6 +121,10 @@ static int parse_args(int argc, char **argv, int *exitcode)
else { else {
const char *arg; const char *arg;
switch (argv[i][1]) { switch (argv[i][1]) {
case 'r':
i = get_arg(argc, argv, 2, i, &arg, 0);
set_param(&global.parameters, "config.rules", arg);
break;
case 'c': case 'c':
i = get_arg(argc, argv, 2, i, &confpath, 0); i = get_arg(argc, argv, 2, i, &confpath, 0);
break; break;
@ -137,10 +141,6 @@ static int parse_args(int argc, char **argv, int *exitcode)
case 'q': case 'q':
verbosity = 0; verbosity = 0;
break; break;
case 'r':
i = get_arg(argc, argv, 2, i, &arg, 0);
turn = atoi(arg);
break;
case 'v': case 'v':
i = get_arg(argc, argv, 2, i, &arg, 0); i = get_arg(argc, argv, 2, i, &arg, 0);
verbosity = arg ? atoi(arg) : 0xff; verbosity = arg ? atoi(arg) : 0xff;

View File

@ -7,5 +7,5 @@ SET ERESSEA=%CD%
CD %SRCDIR% CD %SRCDIR%
mkdir build-vs%VSVERSION% mkdir build-vs%VSVERSION%
cd build-vs%VSVERSION% cd build-vs%VSVERSION%
"%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%ERESSEA%/server/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE .. "%ProgramFiles(x86)%\CMake\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%ProgramFiles(x86)%/Lua/5.1;%ERESSEA%/dependencies-win32" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
PAUSE PAUSE