creport will now print spellbooks

This commit is contained in:
Enno Rehling 2012-05-25 22:54:18 -07:00
parent faa72b66b1
commit 303dd7cc94
4 changed files with 25 additions and 21 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/spell.h>
#include <kernel/spellbook.h> #include <kernel/spellbook.h>
#include <kernel/teleport.h> #include <kernel/teleport.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
@ -651,20 +652,24 @@ fwriteorder(FILE * F, const struct order *ord, const struct locale *lang,
fputc('"', F); fputc('"', F);
} }
static void cr_output_spells(FILE * F, quicklist * slist, const faction * f, static void cr_output_spells(FILE * F, const unit * u, int maxlevel)
int maxlevel)
{ {
if (slist) { spellbook * book = unit_get_spellbook(u);
quicklist *ql;
int qi;
fprintf(F, "SPRUECHE\n");
for (ql = slist, qi = 0; ql; ql_advance(&ql, &qi, 1)) { if (book) {
spell *sp = (spell *) ql_get(ql, qi); const faction * f = u->faction;
if (sp->level <= maxlevel) { quicklist *ql;
const char *name = int qi, header = 0;
add_translation(mkname("spell", sp->sname), spell_name(sp,
f->locale)); for (ql = book->spells, qi = 0; ql; ql_advance(&ql, &qi, 1)) {
spellbook_entry * sbe = (spellbook_entry *)ql_get(ql, qi);
if (sbe->level <= maxlevel) {
spell * sp = sbe->sp;
const char *name = add_translation(mkname("spell", sp->sname), spell_name(sp, f->locale));
if (!header) {
fputs("SPRUECHE\n", F);
header = 1;
}
fprintf(F, "\"%s\"\n", name); fprintf(F, "\"%s\"\n", name);
} }
} }
@ -818,6 +823,7 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
const char *xc; const char *xc;
const char *c; const char *c;
int i; int i;
sc_mage *mage;
i = ualias(u); i = ualias(u);
if (i > 0) if (i > 0)
@ -889,13 +895,12 @@ static void cr_output_unit(FILE * F, const region * r, const faction * f,
f->locale))); f->locale)));
} }
} }
/* spells */
if (is_mage(u)) {
sc_mage *mage = get_mage(u);
quicklist **slistp = get_spelllist(mage, u->faction);
int i, maxlevel = effskill(u, SK_MAGIC);
cr_output_spells(F, *slistp, f, maxlevel); /* spells that this unit can cast */
mage = get_mage(u);
if (mage) {
int i, maxlevel = effskill(u, SK_MAGIC);
cr_output_spells(F, u, maxlevel);
for (i = 0; i != MAXCOMBATSPELLS; ++i) { for (i = 0; i != MAXCOMBATSPELLS; ++i) {
const spell *sp = mage->combatspells[i].sp; const spell *sp = mage->combatspells[i].sp;

View File

@ -1738,7 +1738,7 @@ void unit_add_spell(unit * u, sc_mage * m, struct spell * sp, int level)
add_spellname(mage, sp); add_spellname(mage, sp);
} }
struct spellbook * unit_get_spellbook(struct unit * u) struct spellbook * unit_get_spellbook(const struct unit * u)
{ {
sc_mage * mage = get_mage(u); sc_mage * mage = get_mage(u);
if (mage) { if (mage) {

View File

@ -233,7 +233,7 @@ extern "C" {
int unit_max_hp(const struct unit *u); int unit_max_hp(const struct unit *u);
void scale_number(struct unit *u, int n); void scale_number(struct unit *u, int n);
struct spellbook * unit_get_spellbook(struct unit * u); struct spellbook * unit_get_spellbook(const struct unit * u);
void unit_add_spell(struct unit * u, struct sc_mage * m, struct spell * sp, int level); void unit_add_spell(struct unit * u, struct sc_mage * m, struct spell * sp, int level);
extern struct attrib_type at_creator; extern struct attrib_type at_creator;

View File

@ -1575,7 +1575,6 @@ static int parse_spells(xmlDocPtr doc)
xmlFree(propValue); xmlFree(propValue);
/* level, rank and flags */ /* level, rank and flags */
#endif #endif
sp->level = xml_ivalue(node, "level", -1);
sp->rank = (char)xml_ivalue(node, "rank", -1); sp->rank = (char)xml_ivalue(node, "rank", -1);
if (xml_bvalue(node, "los", false)) if (xml_bvalue(node, "los", false))
sp->sptyp |= TESTCANSEE; /* must see or have contact */ sp->sptyp |= TESTCANSEE; /* must see or have contact */