From 0dcfada50f0cf48709eb9356723c3b81f9d244cc Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 24 Feb 2010 06:42:00 +0000 Subject: [PATCH] better calendar configuration --- src/basic/res/config-basic.xml | 7 +------ src/common/gamecode/report.c | 2 +- src/common/gamecode/summary.c | 2 +- src/common/kernel/version.h | 2 +- src/common/kernel/xmlreader.c | 24 ++++++++++++++---------- src/eressea/res/calendar.xml | 23 ----------------------- src/eressea/res/catalog-e3a.xml | 10 ++++++++++ src/eressea/res/config-e3a.xml | 3 ++- src/eressea/res/config-eressea.xml | 3 ++- src/eressea/res/e3a/calendar.xml | 23 ----------------------- 10 files changed, 32 insertions(+), 67 deletions(-) delete mode 100644 src/eressea/res/calendar.xml create mode 100644 src/eressea/res/catalog-e3a.xml delete mode 100644 src/eressea/res/e3a/calendar.xml diff --git a/src/basic/res/config-basic.xml b/src/basic/res/config-basic.xml index 1573341e5..58587925d 100644 --- a/src/basic/res/config-basic.xml +++ b/src/basic/res/config-basic.xml @@ -7,6 +7,7 @@ + @@ -30,12 +31,6 @@ - - - - - - diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 1bf5199df..3109635a9 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -110,7 +110,7 @@ gamedate_season(const struct locale * lang) LOC(lang, weeknames[gd.week]), LOC(lang, monthnames[gd.month]), gd.year, - LOC(lang, agename), + agename?LOC(lang, agename):"", LOC(lang, seasonnames[gd.season])); return buf; diff --git a/src/common/gamecode/summary.c b/src/common/gamecode/summary.c index dce53337e..067ad62ed 100644 --- a/src/common/gamecode/summary.c +++ b/src/common/gamecode/summary.c @@ -114,7 +114,7 @@ gamedate2(const struct locale * lang) LOC(lang, weeknames2[gd.week]), LOC(lang, monthnames[gd.month]), gd.year, - LOC(lang, agename)); + agename?LOC(lang, agename):""); return buf; } diff --git a/src/common/kernel/version.h b/src/common/kernel/version.h index eaaf99ce6..e1fa52647 100644 --- a/src/common/kernel/version.h +++ b/src/common/kernel/version.h @@ -67,4 +67,4 @@ #define FOSS_VERSION 336 /* the open source release */ #define MIN_VERSION CURSETYPE_VERSION /* minimal datafile we support */ -#define RELEASE_VERSION MOURNING_VERSION /* current datafile */ +#define RELEASE_VERSION FOSS_VERSION /* current datafile */ diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index d46d39dfe..8ad2305d6 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -372,22 +372,24 @@ parse_calendar(xmlDocPtr doc) xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathObjectPtr xpathCalendars; xmlNodeSetPtr nsetCalendars; - int rv = 0; + int c, rv = 0; /* reading eressea/buildings/building */ xpathCalendars = xmlXPathEvalExpression(BAD_CAST "/eressea/calendar", xpath); nsetCalendars = xpathCalendars->nodesetval; - if (nsetCalendars==NULL || nsetCalendars->nodeNr!=1) { - /* rv = -1; */ - } else { - xmlNodePtr calendar = nsetCalendars->nodeTab[0]; + months_per_year = 0; + if (nsetCalendars==NULL || nsetCalendars->nodeNr==0) { + rv = -1; + } else for (c=0;c!=nsetCalendars->nodeNr;++c) { + xmlNodePtr calendar = nsetCalendars->nodeTab[c]; xmlXPathObjectPtr xpathWeeks, xpathMonths, xpathSeasons; xmlNodeSetPtr nsetWeeks, nsetMonths, nsetSeasons; xmlChar * propValue = xmlGetProp(calendar, BAD_CAST "name"); xmlChar * newyear = xmlGetProp(calendar, BAD_CAST "newyear"); - first_turn = xml_ivalue(calendar, "start", 0); + first_turn = xml_ivalue(calendar, "start", first_turn); if (propValue) { + free(agename); agename = strdup(mkname("calendar", (const char*)propValue)); xmlFree(propValue); } @@ -395,10 +397,11 @@ parse_calendar(xmlDocPtr doc) xpath->node = calendar; xpathWeeks = xmlXPathEvalExpression(BAD_CAST "week", xpath); nsetWeeks = xpathWeeks->nodesetval; - if (nsetWeeks!=NULL) { + if (nsetWeeks!=NULL && nsetWeeks->nodeNr) { int i; weeks_per_month = nsetWeeks->nodeNr; + assert(!weeknames); weeknames = malloc(sizeof(char *) * weeks_per_month); weeknames2 = malloc(sizeof(char *) * weeks_per_month); for (i=0;i!=nsetWeeks->nodeNr;++i) { @@ -414,13 +417,13 @@ parse_calendar(xmlDocPtr doc) } xmlXPathFreeObject(xpathWeeks); - months_per_year = 0; xpathSeasons = xmlXPathEvalExpression(BAD_CAST "season", xpath); nsetSeasons = xpathSeasons->nodesetval; - if (nsetSeasons!=NULL) { + if (nsetSeasons!=NULL && nsetSeasons->nodeNr) { int i; seasons = nsetSeasons->nodeNr; + assert(!seasonnames); seasonnames = malloc(sizeof(char *) * seasons); for (i=0;i!=nsetSeasons->nodeNr;++i) { @@ -435,10 +438,11 @@ parse_calendar(xmlDocPtr doc) xpathMonths = xmlXPathEvalExpression(BAD_CAST "season/month", xpath); nsetMonths = xpathMonths->nodesetval; - if (nsetMonths!=NULL) { + if (nsetMonths!=NULL && nsetMonths->nodeNr) { int i; months_per_year = nsetMonths->nodeNr; + assert(!monthnames); monthnames = malloc(sizeof(char *) * months_per_year); month_season = malloc(sizeof(int) * months_per_year); storms = malloc(sizeof(int) * months_per_year); diff --git a/src/eressea/res/calendar.xml b/src/eressea/res/calendar.xml deleted file mode 100644 index 74ce8e54b..000000000 --- a/src/eressea/res/calendar.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/eressea/res/catalog-e3a.xml b/src/eressea/res/catalog-e3a.xml new file mode 100644 index 000000000..8eb4603a3 --- /dev/null +++ b/src/eressea/res/catalog-e3a.xml @@ -0,0 +1,10 @@ + + + + + + diff --git a/src/eressea/res/config-e3a.xml b/src/eressea/res/config-e3a.xml index 528a5c5f0..c1a1699fb 100644 --- a/src/eressea/res/config-e3a.xml +++ b/src/eressea/res/config-e3a.xml @@ -24,7 +24,8 @@ - + + diff --git a/src/eressea/res/config-eressea.xml b/src/eressea/res/config-eressea.xml index 673329eac..6b892dbac 100644 --- a/src/eressea/res/config-eressea.xml +++ b/src/eressea/res/config-eressea.xml @@ -25,7 +25,8 @@ - + + diff --git a/src/eressea/res/e3a/calendar.xml b/src/eressea/res/e3a/calendar.xml deleted file mode 100644 index 199fd1066..000000000 --- a/src/eressea/res/e3a/calendar.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -