diff --git a/src/kernel/race.c b/src/kernel/race.c index 53771a24c..155a1d326 100644 --- a/src/kernel/race.c +++ b/src/kernel/race.c @@ -158,6 +158,7 @@ static race *rc_find_i(const char *name) } if (!rc && strcmp(name, "uruk") == 0) { rc = rc_find_i("orc"); + log_warning("a reference was made to the retired race '%s', returning '%s'.", name, rc->_name); } return rc; } diff --git a/src/kernel/race.h b/src/kernel/race.h index 47fe149e5..b9c541aa1 100644 --- a/src/kernel/race.h +++ b/src/kernel/race.h @@ -146,7 +146,6 @@ extern "C" { int flags; int battle_flags; int ec_flags; - race_t oldfamiliars[MAXMAGIETYP]; struct att attack[RACE_ATTACKS]; signed char bonus[MAXSKILLS]; diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 1343b3908..fca49e8ff 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1613,7 +1613,7 @@ static int parse_races(xmlDocPtr doc) xmlNodePtr node = nodes->nodeTab[i]; xmlNodePtr child; xmlChar *propValue; - race *rc; + race *rc, *frc = 0; xmlXPathObjectPtr result; int k, study_speed_base, attacks; struct att *attack; @@ -1810,21 +1810,27 @@ static int parse_races(xmlDocPtr doc) /* reading eressea/races/race/familiar */ xpath->node = node; result = xmlXPathEvalExpression(BAD_CAST "familiar", xpath); - for (k = 0; k != result->nodesetval->nodeNr; ++k) { - xmlNodePtr node = result->nodesetval->nodeTab[k]; - race *frc; + if (result->nodesetval->nodeNr > MAXMAGIETYP) { + log_error("race %s has %d potential familiars", rc->_name, result->nodesetval->nodeNr); + } + for (k = 0; k != MAXMAGIETYP; ++k) { + if (k < result->nodesetval->nodeNr) { + xmlNodePtr node = result->nodesetval->nodeTab[k]; - propValue = xmlGetProp(node, BAD_CAST "race"); - assert(propValue != NULL); - frc = rc_get_or_create((const char *)propValue); - if (xml_bvalue(node, "default", false)) { - rc->familiars[k] = rc->familiars[0]; - rc->familiars[0] = frc; - } - else { + propValue = xmlGetProp(node, BAD_CAST "race"); + assert(propValue != NULL); + frc = rc_get_or_create((const char *)propValue); + if (xml_bvalue(node, "default", false)) { + rc->familiars[k] = rc->familiars[0]; + rc->familiars[0] = frc; + } + else { + rc->familiars[k] = frc; + } + xmlFree(propValue); + } else { rc->familiars[k] = frc; } - xmlFree(propValue); } xmlXPathFreeObject(result); diff --git a/src/spells.c b/src/spells.c index a2506439b..401f0ac9e 100644 --- a/src/spells.c +++ b/src/spells.c @@ -480,6 +480,7 @@ static const race *select_familiar(const race * magerace, magic_t magiegebiet) assert(magerace->familiars[0]); if (rnd >= 70) { retval = magerace->familiars[magiegebiet]; + assert(retval); } else { retval = magerace->familiars[0];