diff --git a/cutest b/cutest index d83cec09a..788659594 160000 --- a/cutest +++ b/cutest @@ -1 +1 @@ -Subproject commit d83cec09a52835274ab8ed4849de16fb8658982a +Subproject commit 788659594ef87e9f497b8039da764182adfd2943 diff --git a/game-e3/catalog.xml b/game-e3/catalog.xml index 93cda3505..4c55dadd5 100644 --- a/game-e3/catalog.xml +++ b/game-e3/catalog.xml @@ -6,11 +6,11 @@ + rewritePrefix="config/core/" /> + rewritePrefix="config/game/" /> + rewritePrefix="config/default/" /> diff --git a/game-e3/runtests.lua b/game-e3/runtests.lua new file mode 100644 index 000000000..9a167d039 --- /dev/null +++ b/game-e3/runtests.lua @@ -0,0 +1,3 @@ +require "setup" +read_xml("config.xml", "catalog.xml") +run_tests() diff --git a/res/adamantium.xml b/res/adamantium.xml new file mode 100644 index 000000000..315a8d66c --- /dev/null +++ b/res/adamantium.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/config-e3a.xml b/res/config-e3a.xml index 07a3b8eab..22c3bd645 100644 --- a/res/config-e3a.xml +++ b/res/config-e3a.xml @@ -30,6 +30,7 @@ + diff --git a/res/config-eressea.xml b/res/config-eressea.xml index d06464759..579e7e94a 100644 --- a/res/config-eressea.xml +++ b/res/config-eressea.xml @@ -31,6 +31,7 @@ + diff --git a/res/eressea/items.xml b/res/eressea/items.xml index a1efc9620..8fe36ee1b 100644 --- a/res/eressea/items.xml +++ b/res/eressea/items.xml @@ -164,36 +164,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/bindings.c b/src/bindings.c index 7a8e99e3a..6b45bfb2f 100755 --- a/src/bindings.c +++ b/src/bindings.c @@ -995,8 +995,8 @@ static int tolua_get_spells(lua_State * L) int tolua_read_xml(lua_State * L) { - const char *filename = tolua_tostring(L, 1, 0); - const char *catalog = tolua_tostring(L, 2, 0); + const char *filename = tolua_tostring(L, 1, "config.xml"); + const char *catalog = tolua_tostring(L, 2, "catalog.xml"); init_data(filename, catalog); return 0; } @@ -1196,7 +1196,7 @@ lua_State *lua_init(void) { return L; } -int eressea_run(lua_State *L, const char *luafile, const char *entry_point) +int eressea_run(lua_State *L, const char *luafile) { int err = 0; @@ -1206,28 +1206,17 @@ int eressea_run(lua_State *L, const char *luafile, const char *entry_point) log_debug("executing script %s\n", luafile); lua_getglobal(L, "dofile"); lua_pushstring(L, luafile); - err = lua_pcall(L, 1, 0, 0); + err = lua_pcall(L, 1, 1, 0); if (err != 0) { log_lua_error(L); abort(); - return err; - } - } - if (entry_point) { - if (strcmp("console", entry_point)==0) { - return lua_console(L); - } - lua_getglobal(L, entry_point); - if (lua_isfunction(L, -1)) { - log_debug("calling entry-point: %s\n", entry_point); - err = lua_pcall(L, 0, 1, 0); - if (err != 0) { - log_lua_error(L); + } else { + if (lua_isnumber(L, -1)) { + err = (int)lua_tonumber(L, -1); } - return err; - } else { - log_error("unknown entry-point: %s\n", entry_point); + lua_pop(L, 1); } + return err; } - return 0; + return lua_console(L); } diff --git a/src/bindings.h b/src/bindings.h index 1494a1d7c..d1b880609 100755 --- a/src/bindings.h +++ b/src/bindings.h @@ -29,7 +29,7 @@ extern "C" { void lua_done(struct lua_State *L); struct lua_State *lua_init(void); - int eressea_run(struct lua_State *L, const char *luafile, const char *entry_point); + int eressea_run(struct lua_State *L, const char *luafile); #ifdef __cplusplus } diff --git a/src/main.c b/src/main.c index 2246dc389..3729be52e 100644 --- a/src/main.c +++ b/src/main.c @@ -39,7 +39,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. static const char *logfile= "eressea.log"; static const char *luafile = 0; -static const char *entry_point = NULL; static const char *inifile = "eressea.ini"; static int memdebug = 0; @@ -51,8 +50,6 @@ static void parse_config(const char *filename) log_debug("reading from configuration file %s\n", filename); memdebug = iniparser_getint(d, "eressea:memcheck", memdebug); - entry_point = iniparser_getstring(d, "eressea:run", entry_point); - luafile = iniparser_getstring(d, "eressea:load", luafile); /* only one value in the [editor] section */ force_color = iniparser_getint(d, "editor:color", force_color); @@ -99,7 +96,7 @@ static int parse_args(int argc, char **argv, int *exitcode) for (i = 1; i != argc; ++i) { if (argv[i][0] != '-') { - return usage(argv[0], argv[i]); + luafile = argv[i]; } else if (argv[i][1] == '-') { /* long format */ if (strcmp(argv[i] + 2, "version") == 0) { printf("\n%s PBEM host\n" @@ -117,18 +114,12 @@ static int parse_args(int argc, char **argv, int *exitcode) } else { const char *arg; switch (argv[i][1]) { - case 'C': - entry_point = "console"; - break; case 'f': i = get_arg(argc, argv, 2, i, &luafile, 0); break; case 'l': i = get_arg(argc, argv, 2, i, &logfile, 0); break; - case 'e': - i = get_arg(argc, argv, 2, i, &entry_point, 0); - break; case 't': i = get_arg(argc, argv, 2, i, &arg, 0); turn = atoi(arg); @@ -137,7 +128,6 @@ static int parse_args(int argc, char **argv, int *exitcode) verbosity = 0; break; case 'r': - entry_point = "run_turn"; i = get_arg(argc, argv, 2, i, &arg, 0); turn = atoi(arg); break; @@ -270,7 +260,7 @@ int main(int argc, char **argv) register_spells(); bind_monsters(L); - err = eressea_run(L, luafile, entry_point); + err = eressea_run(L, luafile); if (err) { log_error("server execution failed with code %d\n", err); return err; diff --git a/src/util/xml.c b/src/util/xml.c index c97460912..b1647838e 100644 --- a/src/util/xml.c +++ b/src/util/xml.c @@ -113,7 +113,7 @@ int read_xml(const char *filename, const char *catalog) xmlLoadCatalog(catalog); } #ifdef XML_PARSE_XINCLUDE - doc = xmlReadFile(filename, NULL, XML_PARSE_XINCLUDE); + doc = xmlReadFile(filename, NULL, XML_PARSE_XINCLUDE|XML_PARSE_NONET|XML_PARSE_PEDANTIC); #else doc = xmlParseFile(filename); #endif