read spellbook (expat)

This commit is contained in:
Enno Rehling 2018-05-05 07:48:38 +02:00
parent 0e3170a0cb
commit dc3918f4a6

View file

@ -285,13 +285,13 @@ static void XMLCALL start_spellbooks(parseinfo *pi, const XML_Char *el, const XM
handle_bad_input(pi, el, NULL); handle_bad_input(pi, el, NULL);
} }
} }
if (xml_strcmp(el, "entry") == 0) { else if (xml_strcmp(el, "entry") == 0) {
int i, level; int i, level = 0;
const XML_Char *name = NULL; const XML_Char *name = NULL;
assert(sb); assert(sb);
for (i = 0; attr[i]; i += 2) { for (i = 0; attr[i]; i += 2) {
if (xml_strcmp(attr[i], "name") == 0) { if (xml_strcmp(attr[i], "spell") == 0) {
name = attr[i + 1]; name = attr[i + 1];
} }
else if (xml_strcmp(attr[i], "level") == 0) { else if (xml_strcmp(attr[i], "level") == 0) {
@ -301,8 +301,12 @@ static void XMLCALL start_spellbooks(parseinfo *pi, const XML_Char *el, const XM
handle_bad_input(pi, el, attr[i]); handle_bad_input(pi, el, attr[i]);
} }
} }
if (name && level > 0) {
handle_bad_input(pi, el, NULL); spellbook_addref(sb, name, level);
}
else {
handle_bad_input(pi, el, NULL);
}
} }
else { else {
handle_bad_input(pi, el, NULL); handle_bad_input(pi, el, NULL);
@ -876,8 +880,9 @@ static void XMLCALL handle_start(void *data, const XML_Char *el, const XML_Char
else if (xml_strcmp(el, "spells") == 0) { else if (xml_strcmp(el, "spells") == 0) {
pi->type = EXP_SPELLS; pi->type = EXP_SPELLS;
} }
else if (xml_strcmp(el, "spellbooks") == 0) { else if (xml_strcmp(el, "spellbook") == 0) {
pi->type = EXP_SPELLBOOKS; pi->type = EXP_SPELLBOOKS;
start_spellbooks(pi, el, attr);
} }
else if (xml_strcmp(el, "races") == 0) { else if (xml_strcmp(el, "races") == 0) {
pi->type = EXP_RACES; pi->type = EXP_RACES;