fix reading weapon damage.

This commit is contained in:
Enno Rehling 2018-05-04 17:57:10 +02:00
parent 704148e4bd
commit 82ba0e62d4

View file

@ -357,6 +357,24 @@ static void XMLCALL start_weapon(parseinfo *pi, const XML_Char *el, const XML_Ch
++pi->errors;
}
}
else if (xml_strcmp(el, "damage") == 0) {
weapon_type *wtype = rtype->wtype;
int i, pos = 0;
for (i = 0; attr[i]; i += 2) {
if (xml_strcmp(attr[i], "type") == 0) {
/* damage vs. rider(1) or not(0)? */
if (xml_strcmp(attr[i + 1], "rider") == 0) {
pos = 1;
}
}
else if (xml_strcmp(attr[i], "value") == 0) {
wtype->damage[pos] = str_strdup(attr[i + 1]);
}
else {
handle_bad_input(pi, el, NULL);
}
}
}
else {
handle_bad_input(pi, el, NULL);
}
@ -582,29 +600,6 @@ static void start_resources(parseinfo *pi, const XML_Char *el, const XML_Char **
pi->type = EXP_WEAPON;
handle_weapon(pi, el, attr);
}
else if (rtype->wtype) {
weapon_type *wtype = rtype->wtype;
if (xml_strcmp(el, "damage") == 0) {
int i, pos = 0;
for (i = 0; attr[i]; i += 2) {
if (xml_strcmp(attr[i], "type") == 0) {
/* damage vs. rider(1) or not(0)? */
if (xml_strcmp(attr[i + 1], "rider") == 0) {
pos = 1;
}
}
else if (xml_strcmp(attr[i], "value") == 0) {
wtype->damage[pos] = str_strdup(attr[i + 1]);
}
else {
handle_bad_input(pi, el, NULL);
}
}
}
else {
handle_bad_input(pi, el, NULL);
}
}
else {
handle_bad_input(pi, el, NULL);
}