diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index c5e48a914..8266623ad 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -198,76 +198,77 @@ init_mage(attrib * a) { static void free_mage(attrib * a) { - sc_mage * mage = (sc_mage*)a->data.v; - freelist(mage->spellptr); - free(mage); + sc_mage * mage = (sc_mage*)a->data.v; + freelist(mage->spellptr); + free(mage); } static int read_mage(attrib * a, FILE * F) { - int i, mtype; - sc_mage * mage = (sc_mage*)a->data.v; - spell_ptr ** sp = &mage->spellptr; - fscanf(F, "%d %d %d", &mtype, &mage->spellpoints, &mage->spchange); + int i, mtype; + sc_mage * mage = (sc_mage*)a->data.v; + spell_ptr ** sp = &mage->spellptr; + + fscanf(F, "%d %d %d", &mtype, &mage->spellpoints, &mage->spchange); mage->magietyp = (magic_t)mtype; - for (i=0;i!=MAXCOMBATSPELLS;++i) { + for (i=0;i!=MAXCOMBATSPELLS;++i) { int spid; - fscanf (F, "%d %d", &spid, &mage->combatspelllevel[i]); + fscanf (F, "%d %d", &spid, &mage->combatspelllevel[i]); + if (spid<0) spid = SPL_NOSPELL; mage->combatspell[i] = (spellid_t)spid; - } - for (;;) { + } + for (;;) { int spid; - fscanf (F, "%d", &spid); - if (spid < 0) break; + fscanf (F, "%d", &spid); + if (spid < 0) break; *sp = calloc (sizeof(spell_ptr), 1); - (*sp)->spellid = (spellid_t)spid; - sp = &(*sp)->next; - } - return AT_READ_OK; + (*sp)->spellid = (spellid_t)spid; + sp = &(*sp)->next; + } + return AT_READ_OK; } static void write_mage(const attrib * a, FILE * F) { - int i; - sc_mage *mage = (sc_mage*)a->data.v; - spell_ptr *sp = mage->spellptr; - fprintf (F, "%d %d %d ", - mage->magietyp, mage->spellpoints, mage->spchange); - for (i=0;i!=MAXCOMBATSPELLS;++i) { - fprintf (F, "%d %d ", mage->combatspell[i], mage->combatspelllevel[i]); - } - while (sp) { - fprintf (F, "%d ", sp->spellid); - sp = sp->next; - } - fprintf (F, "-1\n"); + int i; + sc_mage *mage = (sc_mage*)a->data.v; + spell_ptr *sp = mage->spellptr; + fprintf(F, "%d %d %d ", mage->magietyp, mage->spellpoints, mage->spchange); + for (i=0;i!=MAXCOMBATSPELLS;++i) { + fprintf(F, "%d %d ", mage->combatspell[i], mage->combatspelllevel[i]); + } + while (sp!=NULL) { + fprintf (F, "%d ", sp->spellid); + sp = sp->next; + } + fprintf (F, "-1\n"); } attrib_type at_mage = { - "mage", - init_mage, - free_mage, - NULL, - write_mage, - read_mage, - ATF_UNIQUE + "mage", + init_mage, + free_mage, + NULL, + write_mage, + read_mage, + ATF_UNIQUE }; boolean is_mage(const unit * u) { - return i2b(get_mage(u) != NULL); + return i2b(get_mage(u) != NULL); } sc_mage * get_mage(const unit * u) { - if (has_skill(u, SK_MAGIC)) { - attrib * a = a_find(u->attribs, &at_mage); - if (a) return a->data.v; - } - return (sc_mage *) NULL; + if (has_skill(u, SK_MAGIC)) { + attrib * a = a_find(u->attribs, &at_mage); + if (a) return a->data.v; + } + return (sc_mage *) NULL; } magic_t @@ -490,7 +491,7 @@ get_combatspell(const unit *u, int nr) m = get_mage(u); if (m) { return find_spellbyid(m->combatspell[nr]); - } else if(u->race->precombatspell != NO_SPELL) { + } else if(u->race->precombatspell != SPL_NOSPELL) { return find_spellbyid(u->race->precombatspell); } diff --git a/src/common/kernel/race.c b/src/common/kernel/race.c index 0f3b3c368..6646e190c 100644 --- a/src/common/kernel/race.c +++ b/src/common/kernel/race.c @@ -76,7 +76,7 @@ rc_new(const char * zName) rc->_name[2] = strdup(zBuffer); sprintf(zBuffer, "%s_x", zName); rc->_name[3] = strdup(zBuffer); - rc->precombatspell = NO_SPELL; + rc->precombatspell = SPL_NOSPELL; return rc; } diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 35443ff66..de6788663 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -7784,7 +7784,6 @@ 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; diff --git a/src/common/kernel/spell.h b/src/common/kernel/spell.h index fa5057e24..13417b270 100644 --- a/src/common/kernel/spell.h +++ b/src/common/kernel/spell.h @@ -28,7 +28,7 @@ extern "C" { /* Sprüche. Neue NUR hinten anfügen, oder das Datenfile geht kaputt */ enum { - SPL_DONOTUSE, + SPL_NOSPELL, SPL_ARTEFAKT_OF_POWER, SPL_ARTEFAKT_OF_AURAPOWER, SPL_ARTEFAKT_OF_REGENERATION, @@ -219,9 +219,7 @@ extern "C" { SPL_WDWPYRAMID_BARDE, SPL_WDWPYRAMID_CHAOS, #endif - SPL_NOSPELL = (spellid_t) -1 }; -#define NO_SPELL SPL_NOSPELL /* Prototypen */ diff --git a/src/common/kernel/xmlreader.c b/src/common/kernel/xmlreader.c index d49a29479..b0e67711a 100644 --- a/src/common/kernel/xmlreader.c +++ b/src/common/kernel/xmlreader.c @@ -774,10 +774,10 @@ parse_races(xmlDocPtr doc) /* reading eressea/races/race/precombatspell */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "precombatspell", xpath); - assert(rc->precombatspell==NO_SPELL || !"precombatspell is already initialized"); + assert(rc->precombatspell==SPL_NOSPELL || !"precombatspell is already initialized"); for (k=0;k!=result->nodesetval->nodeNr;++k) { xmlNodePtr node = result->nodesetval->nodeTab[k]; - rc->precombatspell = (spellid_t)xml_ivalue(node, "spell", NO_SPELL); + rc->precombatspell = (spellid_t)xml_ivalue(node, "spell", SPL_NOSPELL); } xmlXPathFreeObject(result);