Merge pull request #240 from badgerman/feature/bug-2069-familiar-races

bug 2069: familiar races
This commit is contained in:
Enno Rehling 2015-07-02 11:23:25 +02:00
commit 78857d8aa3
4 changed files with 21 additions and 14 deletions

View File

@ -158,6 +158,7 @@ static race *rc_find_i(const char *name)
} }
if (!rc && strcmp(name, "uruk") == 0) { if (!rc && strcmp(name, "uruk") == 0) {
rc = rc_find_i("orc"); rc = rc_find_i("orc");
log_warning("a reference was made to the retired race '%s', returning '%s'.", name, rc->_name);
} }
return rc; return rc;
} }

View File

@ -146,7 +146,6 @@ extern "C" {
int flags; int flags;
int battle_flags; int battle_flags;
int ec_flags; int ec_flags;
race_t oldfamiliars[MAXMAGIETYP];
struct att attack[RACE_ATTACKS]; struct att attack[RACE_ATTACKS];
signed char bonus[MAXSKILLS]; signed char bonus[MAXSKILLS];

View File

@ -1613,7 +1613,7 @@ static int parse_races(xmlDocPtr doc)
xmlNodePtr node = nodes->nodeTab[i]; xmlNodePtr node = nodes->nodeTab[i];
xmlNodePtr child; xmlNodePtr child;
xmlChar *propValue; xmlChar *propValue;
race *rc; race *rc, *frc = 0;
xmlXPathObjectPtr result; xmlXPathObjectPtr result;
int k, study_speed_base, attacks; int k, study_speed_base, attacks;
struct att *attack; struct att *attack;
@ -1810,9 +1810,12 @@ static int parse_races(xmlDocPtr doc)
/* reading eressea/races/race/familiar */ /* reading eressea/races/race/familiar */
xpath->node = node; xpath->node = node;
result = xmlXPathEvalExpression(BAD_CAST "familiar", xpath); result = xmlXPathEvalExpression(BAD_CAST "familiar", xpath);
for (k = 0; k != result->nodesetval->nodeNr; ++k) { 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]; xmlNodePtr node = result->nodesetval->nodeTab[k];
race *frc;
propValue = xmlGetProp(node, BAD_CAST "race"); propValue = xmlGetProp(node, BAD_CAST "race");
assert(propValue != NULL); assert(propValue != NULL);
@ -1825,6 +1828,9 @@ static int parse_races(xmlDocPtr doc)
rc->familiars[k] = frc; rc->familiars[k] = frc;
} }
xmlFree(propValue); xmlFree(propValue);
} else {
rc->familiars[k] = frc;
}
} }
xmlXPathFreeObject(result); xmlXPathFreeObject(result);

View File

@ -480,6 +480,7 @@ static const race *select_familiar(const race * magerace, magic_t magiegebiet)
assert(magerace->familiars[0]); assert(magerace->familiars[0]);
if (rnd >= 70) { if (rnd >= 70) {
retval = magerace->familiars[magiegebiet]; retval = magerace->familiars[magiegebiet];
assert(retval);
} }
else { else {
retval = magerace->familiars[0]; retval = magerace->familiars[0];