at_reportspell is now a message about a spellbook-entry, not just a spell

This commit is contained in:
Enno Rehling 2012-05-24 22:10:18 -07:00
parent 6cb4322c1d
commit 707349d014
3 changed files with 25 additions and 12 deletions

View file

@ -49,6 +49,7 @@ without prior permission by the authors of Eressea.
#include <kernel/resources.h> #include <kernel/resources.h>
#include <kernel/ship.h> #include <kernel/ship.h>
#include <kernel/skill.h> #include <kernel/skill.h>
#include <kernel/spellbook.h>
#include <kernel/teleport.h> #include <kernel/teleport.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/unit.h> #include <kernel/unit.h>
@ -1012,7 +1013,7 @@ static void cr_find_address(FILE * F, const faction * uf, quicklist * addresses)
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ /* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
static void cr_reportspell(FILE * F, spell * sp, const struct locale *lang) static void cr_reportspell(FILE * F, spell * sp, int level, const struct locale *lang)
{ {
int k; int k;
const char *name = const char *name =
@ -1020,7 +1021,7 @@ static void cr_reportspell(FILE * F, spell * sp, const struct locale *lang)
fprintf(F, "ZAUBER %d\n", hashstring(sp->sname)); fprintf(F, "ZAUBER %d\n", hashstring(sp->sname));
fprintf(F, "\"%s\";name\n", name); fprintf(F, "\"%s\";name\n", name);
fprintf(F, "%d;level\n", sp->level); fprintf(F, "%d;level\n", level);
fprintf(F, "%d;rank\n", sp->rank); fprintf(F, "%d;rank\n", sp->rank);
fprintf(F, "\"%s\";info\n", spell_info(sp, lang)); fprintf(F, "\"%s\";info\n", spell_info(sp, lang));
if (sp->parameter) if (sp->parameter)
@ -1567,8 +1568,8 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
cr_find_address(F, f, ctx->addresses); cr_find_address(F, f, ctx->addresses);
a = a_find(f->attribs, &at_reportspell); a = a_find(f->attribs, &at_reportspell);
while (a && a->type == &at_reportspell) { while (a && a->type == &at_reportspell) {
spell *sp = (spell *) a->data.v; spellbook_entry *sbe = (spellbook_entry *) a->data.v;
cr_reportspell(F, sp, f->locale); cr_reportspell(F, sbe->sp, sbe->level, f->locale);
a = a->next; a = a->next;
} }
for (a = a_find(f->attribs, &at_showitem); a && a->type == &at_showitem; for (a = a_find(f->attribs, &at_showitem); a && a->type == &at_showitem;

View file

@ -59,6 +59,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/save.h> #include <kernel/save.h>
#include <kernel/ship.h> #include <kernel/ship.h>
#include <kernel/skill.h> #include <kernel/skill.h>
#include <kernel/spellbook.h>
#include <kernel/teleport.h> #include <kernel/teleport.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/terrainid.h> #include <kernel/terrainid.h>
@ -214,13 +215,14 @@ rparagraph(FILE * F, const char *str, ptrdiff_t indent, int hanging_indent,
} while (*begin); } while (*begin);
} }
static void nr_spell(FILE * F, spell * sp, const struct locale *lang) static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
{ {
int bytes, k, itemanz, costtyp; int bytes, k, itemanz, costtyp;
int dh = 0; int dh = 0;
char buf[4096]; char buf[4096];
char *bufp = buf; char *bufp = buf;
size_t size = sizeof(buf) - 1; size_t size = sizeof(buf) - 1;
spell * sp = sbe->sp;
const char *params = sp->parameter; const char *params = sp->parameter;
rnl(F); rnl(F);
@ -251,7 +253,7 @@ static void nr_spell(FILE * F, spell * sp, const struct locale *lang)
*bufp = 0; *bufp = 0;
rparagraph(F, buf, 0, 0, 0); rparagraph(F, buf, 0, 0, 0);
sprintf(buf, "%s %d", LOC(lang, "nr_spell_level"), sp->level); sprintf(buf, "%s %d", LOC(lang, "nr_spell_level"), sbe->level);
rparagraph(F, buf, 0, 0, 0); rparagraph(F, buf, 0, 0, 0);
sprintf(buf, "%s %d", LOC(lang, "nr_spell_rank"), sp->rank); sprintf(buf, "%s %d", LOC(lang, "nr_spell_rank"), sp->rank);
@ -278,7 +280,7 @@ static void nr_spell(FILE * F, spell * sp, const struct locale *lang)
} }
} else { } else {
if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) { if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) {
itemanz *= sp->level; itemanz *= sbe->level;
} }
bytes = bytes =
snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype,
@ -2301,8 +2303,8 @@ report_plaintext(const char *filename, report_context * ctx,
rnl(F); rnl(F);
centre(F, LOC(f->locale, "section_newspells"), true); centre(F, LOC(f->locale, "section_newspells"), true);
while (a && a->type == &at_reportspell) { while (a && a->type == &at_reportspell) {
spell *sp = (spell *) a->data.v; spellbook_entry *sbe = (spellbook_entry *) a->data.v;
nr_spell(F, sp, f->locale); nr_spell(F, sbe, f->locale);
a = a->next; a = a->next;
} }
} }

View file

@ -86,10 +86,20 @@ const char *magic_school[MAXMAGIETYP] = {
"common" "common"
}; };
attrib_type at_reportspell = { static void a_init_reportspell(struct attrib *a) {
"reportspell", NULL, NULL, NULL, NO_WRITE, NO_READ a->data.v = calloc(1, sizeof(spellbook_entry));
}; }
static void a_finalize_reportspell(struct attrib *a) {
free(a->data.v);
}
attrib_type at_reportspell = {
"reportspell",
a_init_reportspell,
a_finalize_reportspell,
0, NO_WRITE, NO_READ
};
/** /**
** at_icastle ** at_icastle
** TODO: separate castle-appearance from illusion-effects ** TODO: separate castle-appearance from illusion-effects