ill-aligned ids. can only add spells to end, and never remove spells (data file incompatibility)

This commit is contained in:
Enno Rehling 2004-04-10 22:23:43 +00:00
parent aaf7fb2609
commit fa69b66879
2 changed files with 23 additions and 17 deletions

View File

@ -7739,40 +7739,44 @@ get_spellnames(const struct locale * lang, magic_t mtype)
} }
static spell * static spell *
find_spellbyname_i(unit *u, const char *name, const struct locale * lang) find_spellbyname_i(const char *name, const struct locale * lang, magic_t mtype)
{ {
spell_ptr *spt;
sc_mage * m = get_mage(u);
spell * sp = NULL; spell * sp = NULL;
spell_names * sn; spell_names * sn;
if (m==NULL) return NULL; sn = get_spellnames(lang, mtype);
sn = get_spellnames(lang, m->magietyp);
if (findtoken(&sn->names, name, (void**)&sp)==E_TOK_NOMATCH) { if (findtoken(&sn->names, name, (void**)&sp)==E_TOK_NOMATCH) {
magic_t mtype; magic_t mt;
for (mtype=0;mtype!=MAXMAGIETYP;++mtype) { /* if we could not find it in the main magic type, we look through all the others */
sn = get_spellnames(lang, mtype); for (mt=0;mt!=MAXMAGIETYP;++mt) {
sn = get_spellnames(lang, mt);
if (findtoken(&sn->names, name, (void**)&sp)!=E_TOK_NOMATCH) break; if (findtoken(&sn->names, name, (void**)&sp)!=E_TOK_NOMATCH) break;
} }
} }
if (sp!=NULL) { if (sp!=NULL) return sp;
for (spt = m->spellptr; spt; spt = spt->next) {
if (sp->id==spt->spellid) return sp;
}
}
if (lang==default_locale) return NULL; if (lang==default_locale) return NULL;
return find_spellbyname_i(u, name, default_locale); return find_spellbyname_i(name, default_locale, mtype);
} }
spell * spell *
find_spellbyname(unit *u, const char *name, const struct locale * lang) find_spellbyname(unit *u, const char *name, const struct locale * lang)
{ {
spell * sp = find_spellbyname_i(u, name, lang); sc_mage * m = get_mage(u);
if (sp==NULL) { spell * sp;
if (m==NULL) return NULL;
sp = find_spellbyname_i(name, lang, m->magietyp);
if (sp!=NULL) {
spell_ptr *spt;
for (spt = m->spellptr; spt; spt = spt->next) {
if (sp->id==spt->spellid) return sp;
}
} else {
log_warning(("cannot find spell by name: %s\n", name)); log_warning(("cannot find spell by name: %s\n", name));
} }
return sp; return NULL;
} }
spell * spell *
@ -7780,6 +7784,7 @@ find_spellbyid(spellid_t id)
{ {
spell_list * slist; spell_list * slist;
assert(id!=SPL_DONOTUSE);
for (slist=spells;slist!=NULL;slist=slist->next) { for (slist=spells;slist!=NULL;slist=slist->next) {
spell* sp = slist->data; spell* sp = slist->data;
if (sp->id == id) return sp; if (sp->id == id) return sp;

View File

@ -28,6 +28,7 @@ extern "C" {
/* Sprüche. Neue NUR hinten anfügen, oder das Datenfile geht kaputt */ /* Sprüche. Neue NUR hinten anfügen, oder das Datenfile geht kaputt */
enum { enum {
SPL_DONOTUSE,
SPL_ARTEFAKT_OF_POWER, SPL_ARTEFAKT_OF_POWER,
SPL_ARTEFAKT_OF_AURAPOWER, SPL_ARTEFAKT_OF_AURAPOWER,
SPL_ARTEFAKT_OF_REGENERATION, SPL_ARTEFAKT_OF_REGENERATION,