From fc259d232bbcc27f1b9550cf1167ed6e3b6f4926 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 25 May 2012 18:30:18 -0700 Subject: [PATCH] fix spellbook entries in at_reportspell (crash) --- src/gamecode/report.c | 2 +- src/kernel/magic.c | 6 +++++- src/kernel/xmlreader.c | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gamecode/report.c b/src/gamecode/report.c index fe58bf568..6de104b40 100644 --- a/src/gamecode/report.c +++ b/src/gamecode/report.c @@ -280,7 +280,7 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang) } } else { if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { - itemanz *= sbe->level; + itemanz *= sp->level; } bytes = snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, diff --git a/src/kernel/magic.c b/src/kernel/magic.c index 4e57bf5be..85b7e9248 100644 --- a/src/kernel/magic.c +++ b/src/kernel/magic.c @@ -428,7 +428,11 @@ static void update_spells(faction * f, sc_mage * mage, int level, const spellboo add_spellname(mage, sp); } if (!ismonster && !already_seen(f, sp)) { - a_add(&f->attribs, a_new(&at_reportspell))->data.v = sp; + attrib * a = a_new(&at_reportspell); + spellbook_entry * entry = (spellbook_entry *)a->data.v; + entry->level = level; + entry->sp = sp; + a_add(&f->attribs, a); a_add(&f->attribs, a_new(&at_seenspell))->data.v = sp; } } diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 232ed917d..de0da42aa 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1662,8 +1662,14 @@ static int parse_spells(xmlDocPtr doc) propValue = xmlGetProp(node, BAD_CAST "cost"); if (propValue != NULL) { if (strcmp((const char *)propValue, "linear") == 0) { + if ((sp->sptyp&SPELLLEVEL)==0) { + log_error("spell '%s' has linear cost but fixed level\n", sp->sname); + } component->cost = SPC_LINEAR; } else if (strcmp((const char *)propValue, "level") == 0) { + if ((sp->sptyp&SPELLLEVEL)==0) { + log_error("spell '%s' has levelled cost but fixed level\n", sp->sname); + } component->cost = SPC_LEVEL; } xmlFree(propValue);