From 4ab92e3caf1ef59bd5a82d16fb876d180c450464 Mon Sep 17 00:00:00 2001 From: Steffen Mecke Date: Tue, 13 Jan 2015 22:03:09 +0100 Subject: [PATCH] fixed descriptions of spells with parameters (bug #2060+1867) --- res/e3a/spells.xml | 2 +- res/eressea/spells.xml | 4 ++-- src/kernel/xmlreader.c | 10 ++++++++++ src/report.c | 12 ++++++------ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/res/e3a/spells.xml b/res/e3a/spells.xml index 498777952..4bb3470d8 100644 --- a/res/e3a/spells.xml +++ b/res/e3a/spells.xml @@ -585,7 +585,7 @@ - + diff --git a/res/eressea/spells.xml b/res/eressea/spells.xml index 6bd5fc9c4..015d64a7e 100644 --- a/res/eressea/spells.xml +++ b/res/eressea/spells.xml @@ -313,7 +313,7 @@ - + @@ -332,7 +332,7 @@ - + diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 28a351a72..d5aba590b 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1484,6 +1484,16 @@ static int parse_spells(xmlDocPtr doc) sp->sptyp |= FARCASTING; if (xml_bvalue(node, "variable", false)) sp->sptyp |= SPELLLEVEL; + + if (xml_bvalue(node, "buildingtarget", false)) + sp->sptyp |= BUILDINGSPELL; + if (xml_bvalue(node, "shiptarget", false)) + sp->sptyp |= SHIPSPELL; + if (xml_bvalue(node, "unittarget", false)) + sp->sptyp |= UNITSPELL; + if (xml_bvalue(node, "regiontarget", false)) + sp->sptyp |= REGIONSPELL; + k = xml_ivalue(node, "combat", 0); if (k >= 0 && k <= 3) sp->sptyp |= modes[k]; diff --git a/src/report.c b/src/report.c index 42a9e8cdf..6cafe1d9d 100644 --- a/src/report.c +++ b/src/report.c @@ -305,7 +305,7 @@ void nr_spell(stream *out, spellbook_entry * sbe, const struct locale *lang) if (sp->sptyp & SPELLLEVEL) { bytes = _snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype, - itemanz != 1))); + itemanz != 1))); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { @@ -464,24 +464,24 @@ void nr_spell(stream *out, spellbook_entry * sbe, const struct locale *lang) if (sp->sptyp & targetp->flag) ++maxparam; } - if (maxparam > 1) { + if (!maxparam || maxparam > 1) { bytes = (int)strlcpy(bufp, " (", size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } i = 0; for (targetp = targets; targetp->flag; ++targetp) { - if (sp->sptyp & targetp->flag) { + if (!maxparam || sp->sptyp & targetp->flag) { if (i++ != 0) { bytes = (int)strlcpy(bufp, " |", size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER(); } - if (targetp->param) { + if (targetp->param && targetp->vars) { locp = LOC(lang, targetp->vars); bytes = (int)_snprintf(bufp, size, " %s <%s>", parameters[targetp->param], - locp); + locp); if (*params == '+') { ++params; if (wrptr(&bufp, &size, bytes) != 0) @@ -497,7 +497,7 @@ void nr_spell(stream *out, spellbook_entry * sbe, const struct locale *lang) WARN_STATIC_BUFFER(); } } - if (maxparam > 1) { + if (!maxparam || maxparam > 1) { bytes = (int)strlcpy(bufp, " )", size); if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER();