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 *
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_names * sn;
if (m==NULL) 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, mtype);
if (findtoken(&sn->names, name, (void**)&sp)==E_TOK_NOMATCH) {
magic_t mt;
/* if we could not find it in the main magic type, we look through all the others */
for (mt=0;mt!=MAXMAGIETYP;++mt) {
sn = get_spellnames(lang, mt);
if (findtoken(&sn->names, name, (void**)&sp)!=E_TOK_NOMATCH) break;
}
}
if (sp!=NULL) {
for (spt = m->spellptr; spt; spt = spt->next) {
if (sp->id==spt->spellid) return sp;
}
}
if (sp!=NULL) return sp;
if (lang==default_locale) return NULL;
return find_spellbyname_i(u, name, default_locale);
return find_spellbyname_i(name, default_locale, mtype);
}
spell *
find_spellbyname(unit *u, const char *name, const struct locale * lang)
{
spell * sp = find_spellbyname_i(u, name, lang);
if (sp==NULL) {
sc_mage * m = get_mage(u);
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));
}
return sp;
return NULL;
}
spell *
@ -7780,6 +7784,7 @@ find_spellbyid(spellid_t id)
{
spell_list * slist;
assert(id!=SPL_DONOTUSE);
for (slist=spells;slist!=NULL;slist=slist->next) {
spell* sp = slist->data;
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 */
enum {
SPL_DONOTUSE,
SPL_ARTEFAKT_OF_POWER,
SPL_ARTEFAKT_OF_AURAPOWER,
SPL_ARTEFAKT_OF_REGENERATION,