better calendar configuration

This commit is contained in:
Enno Rehling 2010-02-24 06:42:00 +00:00
parent 88c1cebe1e
commit 0dcfada50f
10 changed files with 32 additions and 67 deletions

View File

@ -7,6 +7,7 @@
<xi:include href="eressea:///core/en/strings.xml"/> <xi:include href="eressea:///core/en/strings.xml"/>
<xi:include href="eressea:///core/prefixes.xml"/> <xi:include href="eressea:///core/prefixes.xml"/>
<xi:include href="eressea:///core/calendar.xml"/> <xi:include href="eressea:///core/calendar.xml"/>
<calendar name="thirdage" newyear="month_1" start="0" />
<xi:include href="eressea:///core/common/resources.xml"/> <xi:include href="eressea:///core/common/resources.xml"/>
<xi:include href="armor.xml" /> <xi:include href="armor.xml" />
<xi:include href="weapons.xml" /> <xi:include href="weapons.xml" />
@ -30,12 +31,6 @@
</set> </set>
</equipment> </equipment>
<xi:include href="eressea:///core/names-undead.xml"/>
<xi:include href="eressea:///core/names-skeletons.xml"/>
<xi:include href="eressea:///core/names-zombies.xml"/>
<xi:include href="eressea:///core/names-ghouls.xml"/>
<xi:include href="eressea:///core/names-dragons.xml"/>
<game name="Demonstration"> <game name="Demonstration">
<!-- Game specific settings --> <!-- Game specific settings -->

View File

@ -110,7 +110,7 @@ gamedate_season(const struct locale * lang)
LOC(lang, weeknames[gd.week]), LOC(lang, weeknames[gd.week]),
LOC(lang, monthnames[gd.month]), LOC(lang, monthnames[gd.month]),
gd.year, gd.year,
LOC(lang, agename), agename?LOC(lang, agename):"",
LOC(lang, seasonnames[gd.season])); LOC(lang, seasonnames[gd.season]));
return buf; return buf;

View File

@ -114,7 +114,7 @@ gamedate2(const struct locale * lang)
LOC(lang, weeknames2[gd.week]), LOC(lang, weeknames2[gd.week]),
LOC(lang, monthnames[gd.month]), LOC(lang, monthnames[gd.month]),
gd.year, gd.year,
LOC(lang, agename)); agename?LOC(lang, agename):"");
return buf; return buf;
} }

View File

@ -67,4 +67,4 @@
#define FOSS_VERSION 336 /* the open source release */ #define FOSS_VERSION 336 /* the open source release */
#define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */ #define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */
#define RELEASE_VERSION MOURNING_VERSION /* current datafile */ #define RELEASE_VERSION FOSS_VERSION /* current datafile */

View File

@ -372,22 +372,24 @@ parse_calendar(xmlDocPtr doc)
xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
xmlXPathObjectPtr xpathCalendars; xmlXPathObjectPtr xpathCalendars;
xmlNodeSetPtr nsetCalendars; xmlNodeSetPtr nsetCalendars;
int rv = 0; int c, rv = 0;
/* reading eressea/buildings/building */ /* reading eressea/buildings/building */
xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath); xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath);
nsetCalendars = xpathCalendars->nodesetval; nsetCalendars = xpathCalendars->nodesetval;
if (nsetCalendars==NULL || nsetCalendars->nodeNr!=1) { months_per_year = 0;
/* rv = -1; */ if (nsetCalendars==NULL || nsetCalendars->nodeNr==0) {
} else { rv = -1;
xmlNodePtr calendar = nsetCalendars->nodeTab[0]; } else for (c=0;c!=nsetCalendars->nodeNr;++c) {
xmlNodePtr calendar = nsetCalendars->nodeTab[c];
xmlXPathObjectPtr xpathWeeks, xpathMonths, xpathSeasons; xmlXPathObjectPtr xpathWeeks, xpathMonths, xpathSeasons;
xmlNodeSetPtr nsetWeeks, nsetMonths, nsetSeasons; xmlNodeSetPtr nsetWeeks, nsetMonths, nsetSeasons;
xmlChar * propValue = xmlGetProp(calendar, BAD_CAST "name"); xmlChar * propValue = xmlGetProp(calendar, BAD_CAST "name");
xmlChar * newyear = xmlGetProp(calendar, BAD_CAST "newyear"); xmlChar * newyear = xmlGetProp(calendar, BAD_CAST "newyear");
first_turn = xml_ivalue(calendar, "start", 0); first_turn = xml_ivalue(calendar, "start", first_turn);
if (propValue) { if (propValue) {
free(agename);
agename = strdup(mkname("calendar", (const char*)propValue)); agename = strdup(mkname("calendar", (const char*)propValue));
xmlFree(propValue); xmlFree(propValue);
} }
@ -395,10 +397,11 @@ parse_calendar(xmlDocPtr doc)
xpath->node = calendar; xpath->node = calendar;
xpathWeeks = xmlXPathEvalExpression(BAD_CAST "week", xpath); xpathWeeks = xmlXPathEvalExpression(BAD_CAST "week", xpath);
nsetWeeks = xpathWeeks->nodesetval; nsetWeeks = xpathWeeks->nodesetval;
if (nsetWeeks!=NULL) { if (nsetWeeks!=NULL && nsetWeeks->nodeNr) {
int i; int i;
weeks_per_month = nsetWeeks->nodeNr; weeks_per_month = nsetWeeks->nodeNr;
assert(!weeknames);
weeknames = malloc(sizeof(char *) * weeks_per_month); weeknames = malloc(sizeof(char *) * weeks_per_month);
weeknames2 = malloc(sizeof(char *) * weeks_per_month); weeknames2 = malloc(sizeof(char *) * weeks_per_month);
for (i=0;i!=nsetWeeks->nodeNr;++i) { for (i=0;i!=nsetWeeks->nodeNr;++i) {
@ -414,13 +417,13 @@ parse_calendar(xmlDocPtr doc)
} }
xmlXPathFreeObject(xpathWeeks); xmlXPathFreeObject(xpathWeeks);
months_per_year = 0;
xpathSeasons = xmlXPathEvalExpression(BAD_CAST "season", xpath); xpathSeasons = xmlXPathEvalExpression(BAD_CAST "season", xpath);
nsetSeasons = xpathSeasons->nodesetval; nsetSeasons = xpathSeasons->nodesetval;
if (nsetSeasons!=NULL) { if (nsetSeasons!=NULL && nsetSeasons->nodeNr) {
int i; int i;
seasons = nsetSeasons->nodeNr; seasons = nsetSeasons->nodeNr;
assert(!seasonnames);
seasonnames = malloc(sizeof(char *) * seasons); seasonnames = malloc(sizeof(char *) * seasons);
for (i=0;i!=nsetSeasons->nodeNr;++i) { for (i=0;i!=nsetSeasons->nodeNr;++i) {
@ -435,10 +438,11 @@ parse_calendar(xmlDocPtr doc)
xpathMonths = xmlXPathEvalExpression(BAD_CAST "season/month", xpath); xpathMonths = xmlXPathEvalExpression(BAD_CAST "season/month", xpath);
nsetMonths = xpathMonths->nodesetval; nsetMonths = xpathMonths->nodesetval;
if (nsetMonths!=NULL) { if (nsetMonths!=NULL && nsetMonths->nodeNr) {
int i; int i;
months_per_year = nsetMonths->nodeNr; months_per_year = nsetMonths->nodeNr;
assert(!monthnames);
monthnames = malloc(sizeof(char *) * months_per_year); monthnames = malloc(sizeof(char *) * months_per_year);
month_season = malloc(sizeof(int) * months_per_year); month_season = malloc(sizeof(int) * months_per_year);
storms = malloc(sizeof(int) * months_per_year); storms = malloc(sizeof(int) * months_per_year);

View File

@ -1,23 +0,0 @@
<?xml version="1.0"?>
<calendar name="secondage" newyear="month_1" start="184">
<season name="winter">
<month name="month_4" storm="50" />
<month name="month_5" storm="30" />
<month name="month_6" storm="60" />
</season>
<season name="spring">
<month name="month_7" storm="60" />
<month name="month_8" storm="10" />
</season>
<season name="summer">
<month name="month_9" storm="60" />
<month name="month_1" storm="10" />
</season>
<season name="fall">
<month name="month_2" storm="60" />
<month name="month_3" storm="80" />
</season>
<week name="firstweek" />
<week name="secondweek" />
<week name="thirdweek" />
</calendar>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!DOCTYPE catalog
PUBLIC "-//OASIS/DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
<rewriteURI
uriStartString="eressea:///core/"
rewritePrefix="../../res/" />
</catalog>

View File

@ -24,7 +24,8 @@
<xi:include href="e3a/ships.xml"/> <xi:include href="e3a/ships.xml"/>
<xi:include href="e3a/shipnames.xml"/> <xi:include href="e3a/shipnames.xml"/>
<xi:include href="e3a/terrains.xml"/> <xi:include href="e3a/terrains.xml"/>
<xi:include href="e3a/calendar.xml"/> <xi:include href="eressea:///core/calendar.xml"/>
<calendar name="thirdage" newyear="month_1" start="1"/>
<xi:include href="e3a/items.xml" /> <xi:include href="e3a/items.xml" />
<xi:include href="e3a/strings.xml"/> <xi:include href="e3a/strings.xml"/>
<xi:include href="e3a/messages.xml"/> <xi:include href="e3a/messages.xml"/>

View File

@ -25,7 +25,8 @@
<xi:include href="eressea:///core/directions.xml"/> <xi:include href="eressea:///core/directions.xml"/>
<xi:include href="artrewards.xml"/> <xi:include href="artrewards.xml"/>
<xi:include href="buildings.xml"/> <xi:include href="buildings.xml"/>
<xi:include href="calendar.xml"/> <xi:include href="eressea:///core/calendar.xml"/>
<calendar name="secondage" newyear="month_1" start="184"/>
<xi:include href="equipment.xml"/> <xi:include href="equipment.xml"/>
<xi:include href="items.xml"/> <xi:include href="items.xml"/>
<xi:include href="races.xml"/> <xi:include href="races.xml"/>

View File

@ -1,23 +0,0 @@
<?xml version="1.0"?>
<calendar name="thirdage" newyear="month_1" start="1">
<season name="winter">
<month name="month_4" storm="50" />
<month name="month_5" storm="30" />
<month name="month_6" storm="60" />
</season>
<season name="spring">
<month name="month_7" storm="60" />
<month name="month_8" storm="10" />
</season>
<season name="summer">
<month name="month_9" storm="60" />
<month name="month_1" storm="10" />
</season>
<season name="fall">
<month name="month_2" storm="60" />
<month name="month_3" storm="80" />
</season>
<week name="firstweek" />
<week name="secondweek" />
<week name="thirdweek" />
</calendar>