Das durcheinander mit 0 und -1 bei den spells (SPL_NOSPELL) hoffentlich bereinigt.

This commit is contained in:
Enno Rehling 2004-04-10 22:48:19 +00:00
parent fa69b66879
commit 8d04c6a448
5 changed files with 49 additions and 51 deletions

View File

@ -209,11 +209,13 @@ read_mage(attrib * a, FILE * F)
int i, mtype; int i, mtype;
sc_mage * mage = (sc_mage*)a->data.v; sc_mage * mage = (sc_mage*)a->data.v;
spell_ptr ** sp = &mage->spellptr; spell_ptr ** sp = &mage->spellptr;
fscanf(F, "%d %d %d", &mtype, &mage->spellpoints, &mage->spchange); fscanf(F, "%d %d %d", &mtype, &mage->spellpoints, &mage->spchange);
mage->magietyp = (magic_t)mtype; mage->magietyp = (magic_t)mtype;
for (i=0;i!=MAXCOMBATSPELLS;++i) { for (i=0;i!=MAXCOMBATSPELLS;++i) {
int spid; 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; mage->combatspell[i] = (spellid_t)spid;
} }
for (;;) { for (;;) {
@ -232,12 +234,11 @@ write_mage(const attrib * a, FILE * F) {
int i; int i;
sc_mage *mage = (sc_mage*)a->data.v; sc_mage *mage = (sc_mage*)a->data.v;
spell_ptr *sp = mage->spellptr; spell_ptr *sp = mage->spellptr;
fprintf (F, "%d %d %d ", fprintf(F, "%d %d %d ", mage->magietyp, mage->spellpoints, mage->spchange);
mage->magietyp, mage->spellpoints, mage->spchange);
for (i=0;i!=MAXCOMBATSPELLS;++i) { for (i=0;i!=MAXCOMBATSPELLS;++i) {
fprintf(F, "%d %d ", mage->combatspell[i], mage->combatspelllevel[i]); fprintf(F, "%d %d ", mage->combatspell[i], mage->combatspelllevel[i]);
} }
while (sp) { while (sp!=NULL) {
fprintf (F, "%d ", sp->spellid); fprintf (F, "%d ", sp->spellid);
sp = sp->next; sp = sp->next;
} }
@ -490,7 +491,7 @@ get_combatspell(const unit *u, int nr)
m = get_mage(u); m = get_mage(u);
if (m) { if (m) {
return find_spellbyid(m->combatspell[nr]); 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); return find_spellbyid(u->race->precombatspell);
} }

View File

@ -76,7 +76,7 @@ rc_new(const char * zName)
rc->_name[2] = strdup(zBuffer); rc->_name[2] = strdup(zBuffer);
sprintf(zBuffer, "%s_x", zName); sprintf(zBuffer, "%s_x", zName);
rc->_name[3] = strdup(zBuffer); rc->_name[3] = strdup(zBuffer);
rc->precombatspell = NO_SPELL; rc->precombatspell = SPL_NOSPELL;
return rc; return rc;
} }

View File

@ -7784,7 +7784,6 @@ 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,7 +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_NOSPELL,
SPL_ARTEFAKT_OF_POWER, SPL_ARTEFAKT_OF_POWER,
SPL_ARTEFAKT_OF_AURAPOWER, SPL_ARTEFAKT_OF_AURAPOWER,
SPL_ARTEFAKT_OF_REGENERATION, SPL_ARTEFAKT_OF_REGENERATION,
@ -219,9 +219,7 @@ extern "C" {
SPL_WDWPYRAMID_BARDE, SPL_WDWPYRAMID_BARDE,
SPL_WDWPYRAMID_CHAOS, SPL_WDWPYRAMID_CHAOS,
#endif #endif
SPL_NOSPELL = (spellid_t) -1
}; };
#define NO_SPELL SPL_NOSPELL
/* Prototypen */ /* Prototypen */

View File

@ -774,10 +774,10 @@ parse_races(xmlDocPtr doc)
/* reading eressea/races/race/precombatspell */ /* reading eressea/races/race/precombatspell */
xpath->node = node; xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "precombatspell", xpath); 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) { for (k=0;k!=result->nodesetval->nodeNr;++k) {
xmlNodePtr node = result->nodesetval->nodeTab[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); xmlXPathFreeObject(result);