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) {
rc = rc_find_i("orc");
log_warning("a reference was made to the retired race '%s', returning '%s'.", name, rc->_name);
}
return rc;
}

View File

@ -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];

View File

@ -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);

View File

@ -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];