From bb38c8c86af29e0f34cdcead65bf465ac6fa9bcb Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 27 Oct 2002 09:54:04 +0000 Subject: [PATCH] find_spellbyname sucht auch in fremden gebieten. --- src/common/kernel/magic.c | 28 +++++++++++++++++++++------- src/common/kernel/magic.h | 2 -- src/common/kernel/spell.h | 1 + 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index b243a13b6..909489c4f 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -577,22 +577,36 @@ init_spellnames(const struct locale * lang, magic_t mtype) return spellnames = sn; } +static spell_names * +get_spellnames(const struct locale * lang, magic_t mtype) +{ + spell_names * sn = spellnames; + while (sn) { + if (sn->mtype==mtype && sn->lang==lang) break; + sn=sn->next; + } + if (!sn) return init_spellnames(lang, mtype); + return sn; +} spell * find_spellbyname(unit *u, char *name, const struct locale * lang) { - spell_names * sn = spellnames; spell_ptr *spt; sc_mage * m = get_mage(u); spell * sp; + spell_names * sn; if (!m) return NULL; - while (sn) { - if (sn->mtype==m->magietyp && sn->lang==lang) break; - sn=sn->next; - } - if (!sn) sn = init_spellnames(lang, m->magietyp); - if (findtoken(&sn->names, name, (void**)&sp)==E_TOK_NOMATCH) return NULL; + sn = get_spellnames(lang, m->magietyp); + if (findtoken(&sn->names, name, (void**)&sp)==E_TOK_NOMATCH) { + magic_t mtype; + for(mtype=0;mtype!=MAXMAGIETYP;++mtype) { + sn = get_spellnames(lang, m->magietyp); + if (findtoken(&sn->names, name, (void**)&sp)!=E_TOK_NOMATCH) break; + } + if (mtype==MAXMAGIETYP) return NULL; + } for (spt = m->spellptr; spt; spt = spt->next) { if (sp->id==spt->spellid) return sp; diff --git a/src/common/kernel/magic.h b/src/common/kernel/magic.h index 029cc0813..5695387b2 100644 --- a/src/common/kernel/magic.h +++ b/src/common/kernel/magic.h @@ -188,8 +188,6 @@ typedef int (*cspell_f) (struct fighter*, int, int, struct spell * sp); /* zauber-patzer: */ typedef void (*pspell_f) (castorder *); -extern spell spelldaten[]; - /* besondere Spruchtypen */ #define FARCASTING (1<<0) /* ZAUBER [struct region x y] */ #define SPELLLEVEL (1<<1) /* ZAUBER [STUFE x] */ diff --git a/src/common/kernel/spell.h b/src/common/kernel/spell.h index a16004669..782b96543 100644 --- a/src/common/kernel/spell.h +++ b/src/common/kernel/spell.h @@ -268,5 +268,6 @@ typedef struct wall_data { extern struct attrib_type at_cursewall; extern struct attrib_type at_unitdissolve; +extern struct spell spelldaten[]; #endif