diff --git a/src/kernel/equipment.c b/src/kernel/equipment.c index 11fe594f5..bbd049938 100644 --- a/src/kernel/equipment.c +++ b/src/kernel/equipment.c @@ -214,19 +214,26 @@ equipment *get_equipment(const char *eqname) return eq; } +equipment *create_equipment(const char *eqname) +{ + equipment *eq; + size_t len; + char data[64]; + + eq = (equipment *)calloc(1, sizeof(equipment)); + eq->name = strdup(eqname); + + len = cb_new_kv(eqname, strlen(eqname), &eq, sizeof(eq), data); + assert(len <= sizeof(data)); + cb_insert(&cb_equipments, data, len); + return eq; +} + equipment *get_or_create_equipment(const char *eqname) { equipment *eq = get_equipment(eqname); if (!eq) { - size_t len; - char data[64]; - - eq = (equipment *)calloc(1, sizeof(equipment)); - eq->name = strdup(eqname); - - len = cb_new_kv(eqname, strlen(eqname), &eq, sizeof(eq), data); - assert(len <= sizeof(data)); - cb_insert(&cb_equipments, data, len); + return create_equipment(eqname); } return eq; } diff --git a/src/kernel/equipment.h b/src/kernel/equipment.h index 928182dfb..bc479662d 100644 --- a/src/kernel/equipment.h +++ b/src/kernel/equipment.h @@ -57,6 +57,7 @@ extern "C" { struct equipment *get_or_create_equipment(const char *eqname); struct equipment *get_equipment(const char *eqname); + struct equipment *create_equipment(const char *eqname); void equipment_setitem(struct equipment *eq, const struct item_type *itype, const char *value); diff --git a/src/kernel/messages.h b/src/kernel/messages.h index 4eca65fc1..58558072d 100644 --- a/src/kernel/messages.h +++ b/src/kernel/messages.h @@ -46,10 +46,10 @@ extern "C" { int level; } msglevel; - extern struct message *msg_message(const char *name, const char *sig, ...); - extern struct message *msg_feedback(const struct unit *, struct order *cmd, + struct message *msg_message(const char *name, const char *sig, ...); + struct message *msg_feedback(const struct unit *, struct order *cmd, const char *name, const char *sig, ...); - extern struct message *add_message(struct message_list **pm, + struct message *add_message(struct message_list **pm, struct message *m); void addmessage(struct region *r, struct faction *f, const char *s, msg_t mtype, int level); diff --git a/src/kernel/xmlreader.c b/src/kernel/xmlreader.c index 2ef54b005..57ad5ffad 100644 --- a/src/kernel/xmlreader.c +++ b/src/kernel/xmlreader.c @@ -1069,9 +1069,13 @@ static int parse_equipment(xmlDocPtr doc) xmlChar *propName = xmlGetProp(node, BAD_CAST "name"); if (propName != NULL) { - equipment *eq = get_or_create_equipment((const char *)propName); + equipment *eq = get_equipment((const char *)propName); xmlXPathObjectPtr xpathResult; + if (!eq) { + eq = create_equipment((const char *)propName); + } + xpath->node = node; xpathResult = xmlXPathEvalExpression(BAD_CAST "callback", xpath);