forked from github/server
fix some bugs in reading weapons.
This commit is contained in:
parent
4e2171ace9
commit
85509cdf65
4 changed files with 32 additions and 13 deletions
|
@ -277,7 +277,27 @@ static void XMLCALL start_weapon(parseinfo *pi, const XML_Char *el, const XML_Ch
|
||||||
|
|
||||||
assert(rtype && rtype->wtype);
|
assert(rtype && rtype->wtype);
|
||||||
if (xml_strcmp(el, "function") == 0) {
|
if (xml_strcmp(el, "function") == 0) {
|
||||||
++pi->errors;
|
const XML_Char *name = NULL, *type = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; attr[i]; i += 2) {
|
||||||
|
if (xml_strcmp(attr[i], "name") == 0) {
|
||||||
|
type = attr[i + 1];
|
||||||
|
}
|
||||||
|
else if (xml_strcmp(attr[i], "value") == 0) {
|
||||||
|
name = attr[i + 1];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
handle_bad_input(pi, el, attr[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type && xml_strcmp(type, "attack") == 0) {
|
||||||
|
pf_generic fun = get_function(name);
|
||||||
|
rtype->wtype->attack = (wtype_attack)fun;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
handle_bad_input(pi, el, attr[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (xml_strcmp(el, "modifier") == 0) {
|
else if (xml_strcmp(el, "modifier") == 0) {
|
||||||
const XML_Char *type = NULL;
|
const XML_Char *type = NULL;
|
||||||
|
@ -354,7 +374,7 @@ static void XMLCALL start_weapon(parseinfo *pi, const XML_Char *el, const XML_Ch
|
||||||
mod->race_mask = race_mask;
|
mod->race_mask = race_mask;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
++pi->errors;
|
handle_bad_input(pi, el, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (xml_strcmp(el, "damage") == 0) {
|
else if (xml_strcmp(el, "damage") == 0) {
|
||||||
|
@ -566,14 +586,14 @@ static void start_resources(parseinfo *pi, const XML_Char *el, const XML_Char **
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (xml_strcmp(el, "modifier") == 0) {
|
||||||
|
handle_modifier(pi, el, attr);
|
||||||
|
}
|
||||||
else if (rtype->itype) {
|
else if (rtype->itype) {
|
||||||
item_type *itype = rtype->itype;
|
item_type *itype = rtype->itype;
|
||||||
if (xml_strcmp(el, "construction") == 0) {
|
if (xml_strcmp(el, "construction") == 0) {
|
||||||
itype->construction = parse_construction(pi, el, attr);
|
itype->construction = parse_construction(pi, el, attr);
|
||||||
}
|
}
|
||||||
else if (xml_strcmp(el, "modifier") == 0) {
|
|
||||||
handle_modifier(pi, el, attr);
|
|
||||||
}
|
|
||||||
else if (xml_strcmp(el, "requirement") == 0) {
|
else if (xml_strcmp(el, "requirement") == 0) {
|
||||||
assert(itype->construction);
|
assert(itype->construction);
|
||||||
handle_requirement(pi, el, attr);
|
handle_requirement(pi, el, attr);
|
||||||
|
@ -866,9 +886,6 @@ static void end_weapon(parseinfo *pi, const XML_Char *el) {
|
||||||
nwmods = 0;
|
nwmods = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
handle_bad_input(pi, el, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void end_resources(parseinfo *pi, const XML_Char *el) {
|
static void end_resources(parseinfo *pi, const XML_Char *el) {
|
||||||
|
|
|
@ -1703,9 +1703,11 @@ static int parse_strings(xmlDocPtr doc)
|
||||||
|
|
||||||
void register_xmlreader(void)
|
void register_xmlreader(void)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
xml_register_callback(parse_resources);
|
xml_register_callback(parse_resources);
|
||||||
xml_register_callback(parse_buildings); /* requires resources */
|
xml_register_callback(parse_buildings); /* requires resources */
|
||||||
xml_register_callback(parse_ships); /* requires resources, terrains */
|
xml_register_callback(parse_ships); /* requires resources, terrains */
|
||||||
|
#endif
|
||||||
xml_register_callback(parse_races);
|
xml_register_callback(parse_races);
|
||||||
xml_register_callback(parse_equipment); /* requires resources */
|
xml_register_callback(parse_equipment); /* requires resources */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue