WIP: Familiars check for combat spells in the magician's list of spells, too.

https://bugs.eressea.de/view.php?id=1660
This does not work, because set_combatspell later uses knowsspell to make sure the spell is one the familiar has.
This commit is contained in:
Enno Rehling 2014-12-14 12:55:36 +01:00
parent b506bed4d9
commit 42d75c334d
1 changed files with 45 additions and 29 deletions

View File

@ -2903,40 +2903,56 @@ const char *curse_name(const curse_type * ctype, const struct locale *lang)
return LOC(lang, mkname("spell", ctype->cname)); return LOC(lang, mkname("spell", ctype->cname));
} }
spell *unit_getspell(struct unit *u, const char *name, const struct locale * lang) static void select_spellbook(void **tokens, spellbook *sb, const struct locale * lang) {
{ quicklist * ql;
sc_mage * mage = get_mage(u); int qi;
if (mage) {
variant token;
void * tokens = 0;
spellbook *sb = unit_get_spellbook(u);
if (sb) { assert(sb);
quicklist * ql; assert(lang);
int qi;
for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) { for (qi = 0, ql = sb->spells; ql; ql_advance(&ql, &qi, 1)) {
spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi); spellbook_entry *sbe = (spellbook_entry *)ql_get(ql, qi);
spell *sp = sbe->sp; spell *sp = sbe->sp;
const char *n = spell_name(sp, lang);
if (!n) { const char *n = spell_name(sp, lang);
log_error("no translation in locale %s for spell %s\n", locale_name(lang), sp->sname); if (!n) {
} log_error("no translation in locale %s for spell %s\n", locale_name(lang), sp->sname);
else {
token.v = sp;
addtoken(&tokens, n, token);
}
}
} }
else {
if (tokens) { variant token;
if (findtoken(tokens, name, &token) != E_TOK_NOMATCH) { token.v = sp;
freetokens(tokens); addtoken(tokens, n, token);
return (spell *)token.v;
}
freetokens(tokens);
} }
} }
}
spell *unit_getspell(struct unit *u, const char *name, const struct locale * lang)
{
void * tokens = 0;
spellbook *sb;
sb = unit_get_spellbook(u);
if (sb) {
select_spellbook(&tokens, sb, lang);
}
u = get_familiar_mage(u);
if (u) {
sb = unit_get_spellbook(u);
if (sb) {
select_spellbook(&tokens, sb, lang);
}
}
if (tokens) {
variant token;
if (findtoken(tokens, name, &token) != E_TOK_NOMATCH) {
freetokens(tokens);
return (spell *)token.v;
}
freetokens(tokens);
}
return 0; return 0;
} }