some xmlreader code still required that resources get loaded first.

This commit is contained in:
Enno Rehling 2018-05-04 18:48:14 +02:00
parent 85509cdf65
commit ad0f83dcca
2 changed files with 15 additions and 14 deletions

View File

@ -243,17 +243,16 @@ item_type *it_find(const char *zname)
}
item_type *it_get_or_create(resource_type *rtype) {
item_type * itype;
assert(rtype);
itype = it_find(rtype->_name);
if (!itype) {
if (!rtype->itype) {
item_type * itype;
itype = (item_type *)calloc(sizeof(item_type), 1);
itype->rtype = rtype;
rtype->uchange = res_changeitem;
rtype->itype = itype;
rtype->flags |= RTF_ITEM;
}
itype->rtype = rtype;
rtype->uchange = res_changeitem;
rtype->itype = itype;
rtype->flags |= RTF_ITEM;
return itype;
return rtype->itype;
}
static void lt_register(luxury_type * ltype)

View File

@ -864,10 +864,12 @@ static void add_items(equipment * eq, xmlNodeSetPtr nsetItems)
xmlNodePtr node = nsetItems->nodeTab[i];
xmlChar *propValue;
const struct item_type *itype;
struct resource_type *rtype;
propValue = xmlGetProp(node, BAD_CAST "name");
assert(propValue != NULL);
itype = it_find((const char *)propValue);
rtype = rt_get_or_create((const char *)propValue);
itype = it_get_or_create(rtype);
xmlFree(propValue);
if (itype != NULL) {
propValue = xmlGetProp(node, BAD_CAST "amount");
@ -1705,14 +1707,14 @@ void register_xmlreader(void)
{
#if 0
xml_register_callback(parse_resources);
xml_register_callback(parse_buildings); /* requires resources */
xml_register_callback(parse_ships); /* requires resources, terrains */
xml_register_callback(parse_buildings);
xml_register_callback(parse_ships);
#endif
xml_register_callback(parse_races);
xml_register_callback(parse_equipment); /* requires resources */
xml_register_callback(parse_equipment);
xml_register_callback(parse_spells); /* requires resources */
xml_register_callback(parse_spellbooks); /* requires spells */
xml_register_callback(parse_spells);
xml_register_callback(parse_spellbooks);
xml_register_callback(parse_strings);
xml_register_callback(parse_messages);