BUG 2350: read studyspeed correctly and fix orcs

This commit is contained in:
Steffen Mecke 2017-07-28 09:51:28 +02:00
parent ea457ca292
commit 4fe72b5d28
3 changed files with 15 additions and 6 deletions

View File

@ -1172,7 +1172,7 @@
<familiar race="wolf"/> <familiar race="wolf"/>
<familiar race="rat"/> <familiar race="rat"/>
</race> </race>
<race name="orc" magres="-5" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="orc" studyspeed="-5" magres="-5" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<param name="recruit_multi" value="0.5"/> <param name="recruit_multi" value="0.5"/>
<skill name="alchemy" modifier="1"/> <skill name="alchemy" modifier="1"/>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" ?> <?xml version="1.0" ?>
<race name="orc" magres="-5" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes"> <race name="orc" studyspeed="-5" magres="-5" maxaura="1.000000" regaura="1.000000" recruitcost="70" maintenance="10" weight="1000" capacity="540" speed="1.000000" hp="24" damage="1d5" unarmedattack="-2" unarmeddefense="-2" playerrace="yes" walk="yes" giveperson="yes" giveunit="yes" getitem="yes" equipment="yes">
<ai splitsize="10000" moverandom="yes" learn="yes"/> <ai splitsize="10000" moverandom="yes" learn="yes"/>
<param name="recruit_multi" value="0.5"/> <param name="recruit_multi" value="0.5"/>
<skill name="alchemy" modifier="1"/> <skill name="alchemy" modifier="1"/>

View File

@ -1320,6 +1320,12 @@ static void parse_ai(race * rc, xmlNodePtr node)
rc->flags |= RCF_ATTACK_MOVED; rc->flags |= RCF_ATTACK_MOVED;
} }
static void set_study_speed(race *rc, skill_t sk, int modifier){
if (!rc->study_speed)
rc->study_speed = calloc(1, MAXSKILLS);
rc->study_speed[sk] = (char)modifier;
}
static int parse_races(xmlDocPtr doc) static int parse_races(xmlDocPtr doc)
{ {
xmlXPathContextPtr xpath = xmlXPathNewContext(doc); xmlXPathContextPtr xpath = xmlXPathNewContext(doc);
@ -1338,6 +1344,7 @@ static int parse_races(xmlDocPtr doc)
xmlXPathObjectPtr result; xmlXPathObjectPtr result;
int k, study_speed_base, attacks; int k, study_speed_base, attacks;
struct att *attack; struct att *attack;
skill_t sk;
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL); assert(propValue != NULL);
@ -1362,6 +1369,11 @@ static int parse_races(xmlDocPtr doc)
rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints); rc->hitpoints = xml_ivalue(node, "hp", rc->hitpoints);
rc->armor = (char)xml_ivalue(node, "ac", rc->armor); rc->armor = (char)xml_ivalue(node, "ac", rc->armor);
study_speed_base = xml_ivalue(node, "studyspeed", 0); study_speed_base = xml_ivalue(node, "studyspeed", 0);
if (study_speed_base != 0) {
for (sk = 0; sk < MAXSKILLS; ++sk) {
set_study_speed(rc, sk, study_speed_base);
}
}
rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2); rc->at_default = (char)xml_ivalue(node, "unarmedattack", -2);
rc->df_default = (char)xml_ivalue(node, "unarmeddefense", -2); rc->df_default = (char)xml_ivalue(node, "unarmeddefense", -2);
@ -1471,7 +1483,6 @@ static int parse_races(xmlDocPtr doc)
xmlNodePtr node = result->nodesetval->nodeTab[k]; xmlNodePtr node = result->nodesetval->nodeTab[k];
int mod = xml_ivalue(node, "modifier", 0); int mod = xml_ivalue(node, "modifier", 0);
int speed = xml_ivalue(node, "speed", study_speed_base); int speed = xml_ivalue(node, "speed", study_speed_base);
skill_t sk;
propValue = xmlGetProp(node, BAD_CAST "name"); propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL); assert(propValue != NULL);
@ -1479,9 +1490,7 @@ static int parse_races(xmlDocPtr doc)
if (sk != NOSKILL) { if (sk != NOSKILL) {
rc->bonus[sk] = (char)mod; rc->bonus[sk] = (char)mod;
if (speed) { if (speed) {
if (!rc->study_speed) set_study_speed(rc, sk, speed);
rc->study_speed = calloc(1, MAXSKILLS);
rc->study_speed[sk] = (char)speed;
} }
} }
else { else {