remove -Cef, parse any arguments as a file to run.

new xml config file, work in progress, xinclude is broken
This commit is contained in:
Enno Rehling 2014-04-24 14:41:04 +02:00
parent a485f65562
commit c1b840b0b2
6 changed files with 20 additions and 38 deletions

View file

@ -6,11 +6,11 @@
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="config:///core/"
rewritePrefix="../core/res/" />
rewritePrefix="config/core/" />
<rewriteURI
uriStartString="config:///game/"
rewritePrefix="../res/e3a/" />
rewritePrefix="config/game/" />
<rewriteURI
uriStartString="config:///default/"
rewritePrefix="../res/" />
rewritePrefix="config/default/" />
</catalog>

3
game-e3/runtests.lua Normal file
View file

@ -0,0 +1,3 @@
require "setup"
read_xml("config.xml", "catalog.xml")
run_tests()

View file

@ -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);
}

View file

@ -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
}

View file

@ -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;

View file

@ -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