Merge branch 'master' of github.com:eressea/server

This commit is contained in:
Enno Rehling 2014-04-24 05:43:44 -07:00
commit fece511afb
11 changed files with 59 additions and 71 deletions

2
cutest

@ -1 +1 @@
Subproject commit d83cec09a52835274ab8ed4849de16fb8658982a Subproject commit 788659594ef87e9f497b8039da764182adfd2943

View File

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

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

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

36
res/adamantium.xml Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="iso-8859-1" ?>
<resources>
<resource name="adamantium" limited="yes" material="rm_adamantium">
<item weight="200" score="200">
<construction skill="mining" minskill="8" reqsize="1"/>
</item>
<resourcelimit>
<modifier type="require" building="mine"/>
<guard flag="mining"/>
</resourcelimit>
</resource>
<resource name="adamantiumaxe">
<item weight="100" score="500">
<construction skill="weaponsmithing" minskill="8" reqsize="1">
<requirement type="adamantium" quantity="1"/>
<requirement type="log" quantity="1"/>
</construction>
<weapon cut="true" skill="melee" offmod="2" defmod="-2" magres="0.30">
<damage type="rider" value="3d4+15"/>
<damage type="footman" value="3d4+15"/>
</weapon>
</item>
</resource>
<resource name="adamantiumplate">
<item weight="100" score="2000">
<construction skill="armorer" minskill="10" reqsize="1">
<requirement type="adamantium" quantity="3"/>
</construction>
<armor ac="7" penalty="0.1"/>
</item>
</resource>
</resources>

View File

@ -30,6 +30,7 @@
<xi:include href="e3a/weapons.xml" /> <xi:include href="e3a/weapons.xml" />
<xi:include href="e3a/armor.xml" /> <xi:include href="e3a/armor.xml" />
<xi:include href="e3a/resources.xml" /> <xi:include href="e3a/resources.xml" />
<xi:include href="adamantium.xml"/>
<equipment> <equipment>
<set name="first_unit"> <set name="first_unit">

View File

@ -31,6 +31,7 @@
<xi:include href="eressea/items.xml"/> <xi:include href="eressea/items.xml"/>
<xi:include href="eressea/spells.xml"/> <xi:include href="eressea/spells.xml"/>
<xi:include href="eressea/strings.xml"/> <xi:include href="eressea/strings.xml"/>
<xi:include href="adamantium.xml"/>
<equipment> <equipment>
<set name="first_unit"> <set name="first_unit">
<item name="conquesttoken" amount="1"/> <item name="conquesttoken" amount="1"/>

View File

@ -164,36 +164,4 @@
</resource> </resource>
<!-- christmas items: end --> <!-- christmas items: end -->
<resource name="adamantium" limited="yes" material="rm_adamantium">
<item weight="200" score="200">
<construction skill="mining" minskill="8" reqsize="1"/>
</item>
<resourcelimit>
<modifier type="require" building="mine"/>
<guard flag="mining"/>
</resourcelimit>
</resource>
<resource name="adamantiumaxe">
<item weight="100" score="500">
<construction skill="weaponsmithing" minskill="8" reqsize="1">
<requirement type="adamantium" quantity="1"/>
<requirement type="log" quantity="1"/>
</construction>
<weapon cut="true" skill="melee" offmod="2" defmod="-2" magres="0.30">
<damage type="rider" value="3d4+15"/>
<damage type="footman" value="3d4+15"/>
</weapon>
</item>
</resource>
<resource name="adamantiumplate">
<item weight="100" score="2000">
<construction skill="armorer" minskill="10" reqsize="1">
<requirement type="adamantium" quantity="3"/>
</construction>
<armor ac="7" penalty="0.1"/>
</item>
</resource>
</resources> </resources>

View File

@ -995,8 +995,8 @@ static int tolua_get_spells(lua_State * L)
int tolua_read_xml(lua_State * L) int tolua_read_xml(lua_State * L)
{ {
const char *filename = tolua_tostring(L, 1, 0); const char *filename = tolua_tostring(L, 1, "config.xml");
const char *catalog = tolua_tostring(L, 2, 0); const char *catalog = tolua_tostring(L, 2, "catalog.xml");
init_data(filename, catalog); init_data(filename, catalog);
return 0; return 0;
} }
@ -1196,7 +1196,7 @@ lua_State *lua_init(void) {
return L; 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; 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); log_debug("executing script %s\n", luafile);
lua_getglobal(L, "dofile"); lua_getglobal(L, "dofile");
lua_pushstring(L, luafile); lua_pushstring(L, luafile);
err = lua_pcall(L, 1, 0, 0); err = lua_pcall(L, 1, 1, 0);
if (err != 0) { if (err != 0) {
log_lua_error(L); log_lua_error(L);
abort(); 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);
}
return err;
} else { } else {
log_error("unknown entry-point: %s\n", entry_point); if (lua_isnumber(L, -1)) {
err = (int)lua_tonumber(L, -1);
} }
lua_pop(L, 1);
} }
return 0; return err;
}
return lua_console(L);
} }

View File

@ -29,7 +29,7 @@ extern "C" {
void lua_done(struct lua_State *L); void lua_done(struct lua_State *L);
struct lua_State *lua_init(void); 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 #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 *logfile= "eressea.log";
static const char *luafile = 0; static const char *luafile = 0;
static const char *entry_point = NULL;
static const char *inifile = "eressea.ini"; static const char *inifile = "eressea.ini";
static int memdebug = 0; static int memdebug = 0;
@ -51,8 +50,6 @@ static void parse_config(const char *filename)
log_debug("reading from configuration file %s\n", filename); log_debug("reading from configuration file %s\n", filename);
memdebug = iniparser_getint(d, "eressea:memcheck", memdebug); 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 */ /* only one value in the [editor] section */
force_color = iniparser_getint(d, "editor:color", force_color); 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) { for (i = 1; i != argc; ++i) {
if (argv[i][0] != '-') { if (argv[i][0] != '-') {
return usage(argv[0], argv[i]); luafile = argv[i];
} else if (argv[i][1] == '-') { /* long format */ } else if (argv[i][1] == '-') { /* long format */
if (strcmp(argv[i] + 2, "version") == 0) { if (strcmp(argv[i] + 2, "version") == 0) {
printf("\n%s PBEM host\n" printf("\n%s PBEM host\n"
@ -117,18 +114,12 @@ 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 'C':
entry_point = "console";
break;
case 'f': case 'f':
i = get_arg(argc, argv, 2, i, &luafile, 0); i = get_arg(argc, argv, 2, i, &luafile, 0);
break; break;
case 'l': case 'l':
i = get_arg(argc, argv, 2, i, &logfile, 0); i = get_arg(argc, argv, 2, i, &logfile, 0);
break; break;
case 'e':
i = get_arg(argc, argv, 2, i, &entry_point, 0);
break;
case 't': case 't':
i = get_arg(argc, argv, 2, i, &arg, 0); i = get_arg(argc, argv, 2, i, &arg, 0);
turn = atoi(arg); turn = atoi(arg);
@ -137,7 +128,6 @@ static int parse_args(int argc, char **argv, int *exitcode)
verbosity = 0; verbosity = 0;
break; break;
case 'r': case 'r':
entry_point = "run_turn";
i = get_arg(argc, argv, 2, i, &arg, 0); i = get_arg(argc, argv, 2, i, &arg, 0);
turn = atoi(arg); turn = atoi(arg);
break; break;
@ -270,7 +260,7 @@ int main(int argc, char **argv)
register_spells(); register_spells();
bind_monsters(L); bind_monsters(L);
err = eressea_run(L, luafile, entry_point); err = eressea_run(L, luafile);
if (err) { if (err) {
log_error("server execution failed with code %d\n", err); log_error("server execution failed with code %d\n", err);
return err; return err;

View File

@ -113,7 +113,7 @@ int read_xml(const char *filename, const char *catalog)
xmlLoadCatalog(catalog); xmlLoadCatalog(catalog);
} }
#ifdef XML_PARSE_XINCLUDE #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 #else
doc = xmlParseFile(filename); doc = xmlParseFile(filename);
#endif #endif