reorganizing the way configuration data is read (WIP)

This commit is contained in:
Enno Rehling 2014-04-20 09:36:25 -07:00
parent ae68a1beaf
commit fa5dc43b98
9 changed files with 113 additions and 86 deletions

2
cutest

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

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?>
<buildings xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="../buildings/castle-2.xml" />
<xi:include href="config:///default/buildings/castle-2.xml" />
<building name="watch" capacity="1" maxsize="10">
<function name="name" value="fort_name"/>

View File

@ -3,10 +3,34 @@
<!-- begin main races -->
<xi:include href="../races/goblin-3.xml"/>
<xi:include href="../races/wyrm.xml"/>
<xi:include href="../races/dragon.xml"/>
<xi:include href="../races/youngdragon.xml"/>
<xi:include href="config:///default/races/goblin-3.xml"/>
<xi:include href="config:///default/races/wyrm.xml"/>
<xi:include href="config:///default/races/dragon.xml"/>
<xi:include href="config:///default/races/youngdragon.xml"/>
<race name="lynx" magres="0.000000" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="20" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="5" walk="yes" teach="no" giveitem="yes" getitem="yes">
<ai splitsize="99999"/>
<function name="initfamiliar" value="oldfamiliars"/>
<skill name="crossbow" modifier="-99"/>
<skill name="mining" modifier="-99"/>
<skill name="bow" modifier="-99"/>
<skill name="building" modifier="-99"/>
<skill name="forestry" modifier="-99"/>
<skill name="catapult" modifier="-99"/>
<skill name="training" modifier="1"/>
<skill name="riding" modifier="-99"/>
<skill name="armorer" modifier="-99"/>
<skill name="shipcraft" modifier="-99"/>
<skill name="melee" modifier="-99"/>
<skill name="sailing" modifier="-99"/>
<skill name="polearm" modifier="-99"/>
<skill name="quarrying" modifier="-99"/>
<skill name="roadwork" modifier="-99"/>
<skill name="tactics" modifier="-99"/>
<skill name="weaponsmithing" modifier="-99"/>
<skill name="cartmaking" modifier="-99"/>
<attack type="4" damage="2d3"/>
</race>
<race name="human" magres="0.000000" maxaura="1.0" regaura="1.0" recruitcost="100" maintenance="10" weight="1000" capacity="540" speed="1.0" hp="20" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveitem="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/>
@ -583,29 +607,6 @@
<attack type="4" damage="3d20"/>
<attack type="8" damage="1d10"/>
</race>
<race name="lynx" magres="0.000000" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="20" damage="2d3" unarmedattack="0" unarmeddefense="0" attackmodifier="4" defensemodifier="5" walk="yes" teach="no" giveitem="yes" getitem="yes">
<ai splitsize="99999"/>
<function name="initfamiliar" value="oldfamiliars"/>
<skill name="crossbow" modifier="-99"/>
<skill name="mining" modifier="-99"/>
<skill name="bow" modifier="-99"/>
<skill name="building" modifier="-99"/>
<skill name="forestry" modifier="-99"/>
<skill name="catapult" modifier="-99"/>
<skill name="training" modifier="1"/>
<skill name="riding" modifier="-99"/>
<skill name="armorer" modifier="-99"/>
<skill name="shipcraft" modifier="-99"/>
<skill name="melee" modifier="-99"/>
<skill name="sailing" modifier="-99"/>
<skill name="polearm" modifier="-99"/>
<skill name="quarrying" modifier="-99"/>
<skill name="roadwork" modifier="-99"/>
<skill name="tactics" modifier="-99"/>
<skill name="weaponsmithing" modifier="-99"/>
<skill name="cartmaking" modifier="-99"/>
<attack type="4" damage="2d3"/>
</race>
<race name="direwolf" magres="0.000000" maxaura="0.000000" regaura="0.000000" weight="500" capacity="540" speed="1.0" hp="20" damage="2d4" unarmedattack="0" unarmeddefense="0" attackmodifier="3" defensemodifier="1" walk="yes" teach="no" giveperson="yes">
<function name="initfamiliar" value="oldfamiliars"/>
<ai splitsize="5000"/>

View File

@ -2,13 +2,13 @@
<resources xmlns:xi="http://www.w3.org/2001/XInclude">
<!-- this file contains resources that can be mined in some way (anything with a resourcelimit) -->
<xi:include href="eressea:///core/resources/cart.xml"/>
<xi:include href="eressea:///core/resources/horse.xml"/>
<xi:include href="eressea:///core/resources/hp.xml"/>
<xi:include href="eressea:///core/resources/laen.xml"/>
<xi:include href="eressea:///core/resources/log.xml"/>
<xi:include href="eressea:///core/resources/mallorn.xml"/>
<xi:include href="eressea:///core/resources/peasant.xml"/>
<xi:include href="config:///core/resources/cart.xml"/>
<xi:include href="config:///core/resources/horse.xml"/>
<xi:include href="config:///core/resources/hp.xml"/>
<xi:include href="config:///core/resources/laen.xml"/>
<xi:include href="config:///core/resources/log.xml"/>
<xi:include href="config:///core/resources/mallorn.xml"/>
<xi:include href="config:///core/resources/peasant.xml"/>
<xi:include href="resources/iron.xml"/>
<xi:include href="resources/mallornseed.xml"/>
<xi:include href="resources/seed.xml"/>

View File

@ -1,25 +1,25 @@
<?xml version="1.0"?>
<resources xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="eressea:///core/weapons/axe.xml"/>
<xi:include href="eressea:///core/weapons/bow.xml"/>
<xi:include href="eressea:///core/weapons/catapult.xml"/>
<xi:include href="eressea:///core/weapons/lance.xml"/>
<xi:include href="eressea:///core/weapons/mallornbow.xml"/>
<xi:include href="eressea:///core/weapons/mallornspear.xml"/>
<xi:include href="eressea:///core/weapons/rep_crossbow.xml"/>
<xi:include href="eressea:///core/weapons/runesword.xml"/>
<xi:include href="eressea:///core/weapons/rustyaxe.xml"/>
<xi:include href="eressea:///core/weapons/rustysword.xml"/>
<xi:include href="eressea:///core/weapons/spear.xml"/>
<xi:include href="eressea:///core/weapons/sword.xml"/>
<xi:include href="eressea:///core/weapons/firesword.xml"/>
<xi:include href="weapons/crossbow.xml"/>
<xi:include href="weapons/greatbow.xml"/>
<xi:include href="weapons/greatsword.xml"/>
<xi:include href="weapons/halberd.xml"/>
<xi:include href="weapons/laensword.xml"/>
<xi:include href="weapons/mallorncrossbow.xml"/>
<xi:include href="weapons/mallornlance.xml"/>
<xi:include href="weapons/rustygreatsword.xml"/>
<xi:include href="weapons/rustyhalberd.xml"/>
<xi:include href="config:///core/weapons/axe.xml"/>
<xi:include href="config:///core/weapons/bow.xml"/>
<xi:include href="config:///core/weapons/catapult.xml"/>
<xi:include href="config:///core/weapons/lance.xml"/>
<xi:include href="config:///core/weapons/mallornbow.xml"/>
<xi:include href="config:///core/weapons/mallornspear.xml"/>
<xi:include href="config:///core/weapons/rep_crossbow.xml"/>
<xi:include href="config:///core/weapons/runesword.xml"/>
<xi:include href="config:///core/weapons/rustyaxe.xml"/>
<xi:include href="config:///core/weapons/rustysword.xml"/>
<xi:include href="config:///core/weapons/spear.xml"/>
<xi:include href="config:///core/weapons/sword.xml"/>
<xi:include href="config:///core/weapons/firesword.xml"/>
<xi:include href="config:///game/weapons/crossbow.xml"/>
<xi:include href="config:///game/weapons/greatbow.xml"/>
<xi:include href="config:///game/weapons/greatsword.xml"/>
<xi:include href="config:///game/weapons/halberd.xml"/>
<xi:include href="config:///game/weapons/laensword.xml"/>
<xi:include href="config:///game/weapons/mallorncrossbow.xml"/>
<xi:include href="config:///game/weapons/mallornlance.xml"/>
<xi:include href="config:///game/weapons/rustygreatsword.xml"/>
<xi:include href="config:///game/weapons/rustyhalberd.xml"/>
</resources>

19
s/install Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
ROOT=$(pwd)
while [ ! -d $ROOT/.git ]; do
ROOT=$(dirname $ROOT)
if [ "$ROOT" == "/" ; then
echo "could not find root, are you in the git repository?"
exit
fi
done
MACHINE=`uname -m`
[ -z "$CC" ] && [ ! -z `which gcc` ] && CC="gcc"
[ -z "$CC" ] && [ ! -z `which tcc` ] && CC="tcc"
[ -z "$CC" ] && [ ! -z `which cc` ] && CC="cc"
BIN_DIR="build-$MACHINE-$CC-Debug"
cd $ROOT/$BIN_DIR
make install
cd -

View File

@ -1214,6 +1214,9 @@ int eressea_run(lua_State *L, const char *luafile, const char *entry_point)
}
}
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);
@ -1226,5 +1229,5 @@ int eressea_run(lua_State *L, const char *luafile, const char *entry_point)
log_error("unknown entry-point: %s\n", entry_point);
}
}
return lua_console(L);
return 0;
}

View File

@ -72,6 +72,7 @@ static int usage(const char *prog, const char *arg)
}
fprintf(stderr, "Usage: %s [options]\n"
"-t <turn> : read this datafile, not the most current one\n"
"-f <script.lua> : execute a lua script\n"
"-q : be quite (same as -v 0)\n"
"-v <level> : verbosity level\n"
"-C : run in interactive mode\n"
@ -117,7 +118,10 @@ static int parse_args(int argc, char **argv, int *exitcode)
const char *arg;
switch (argv[i][1]) {
case 'C':
entry_point = NULL;
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);

View File

@ -118,7 +118,7 @@ int read_xml(const char *filename, const char *catalog)
doc = xmlParseFile(filename);
#endif
if (doc == NULL) {
log_error("could not open %s\n", filename);
log_error("could not open '%s'\n", filename);
return -1;
}