forked from github/server
code duplication, lazy_spell was almost the same as spellref.
This commit is contained in:
parent
456d1bd196
commit
7009f26ee5
2 changed files with 15 additions and 18 deletions
|
@ -87,8 +87,7 @@ void equipment_setskill(equipment * eq, skill_t sk, const char *value)
|
|||
}
|
||||
|
||||
typedef struct lazy_spell {
|
||||
char *name;
|
||||
struct spell *sp;
|
||||
struct spellref *spref;
|
||||
int level;
|
||||
} lazy_spell;
|
||||
|
||||
|
@ -96,9 +95,8 @@ void equipment_addspell(equipment * eq, const char * name, int level)
|
|||
{
|
||||
if (eq) {
|
||||
lazy_spell *ls = malloc(sizeof(lazy_spell));
|
||||
ls->sp = NULL;
|
||||
ls->spref = spellref_create(NULL, name);
|
||||
ls->level = level;
|
||||
ls->name = strdup(name);
|
||||
selist_push(&eq->spells, ls);
|
||||
}
|
||||
}
|
||||
|
@ -162,12 +160,8 @@ void equip_unit_mask(struct unit *u, const struct equipment *eq, int mask)
|
|||
|
||||
for (qi = 0; ql; selist_advance(&ql, &qi, 1)) {
|
||||
lazy_spell *sbe = (lazy_spell *)selist_get(ql, qi);
|
||||
if (!sbe->sp) {
|
||||
sbe->sp = find_spell(sbe->name);
|
||||
free(sbe->name);
|
||||
sbe->name = NULL;
|
||||
}
|
||||
unit_add_spell(u, mage, sbe->sp, sbe->level);
|
||||
spell *sp = spellref_get(sbe->spref);
|
||||
unit_add_spell(u, mage, sp, sbe->level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +232,7 @@ void equip_items(struct item **items, const struct equipment *eq)
|
|||
|
||||
void free_ls(void *arg) {
|
||||
lazy_spell *ls = (lazy_spell*)arg;
|
||||
free(ls->name);
|
||||
spellref_free(ls->spref);
|
||||
free(ls);
|
||||
}
|
||||
|
||||
|
|
|
@ -2068,17 +2068,20 @@ static int parse_strings(xmlDocPtr doc)
|
|||
|
||||
void register_xmlreader(void)
|
||||
{
|
||||
xml_register_callback(parse_strings);
|
||||
xml_register_callback(parse_messages);
|
||||
xml_register_callback(parse_resources);
|
||||
xml_register_callback(parse_rules);
|
||||
|
||||
xml_register_callback(parse_buildings); /* requires resources */
|
||||
xml_register_callback(parse_ships); /* requires terrains */
|
||||
xml_register_callback(parse_races);
|
||||
xml_register_callback(parse_calendar);
|
||||
xml_register_callback(parse_resources);
|
||||
|
||||
xml_register_callback(parse_buildings); /* requires resources */
|
||||
xml_register_callback(parse_ships); /* requires resources, terrains */
|
||||
xml_register_callback(parse_equipment); /* requires resources */
|
||||
|
||||
xml_register_callback(parse_spells); /* requires resources */
|
||||
xml_register_callback(parse_equipment); /* requires spells */
|
||||
xml_register_callback(parse_spellbooks); /* requires spells */
|
||||
|
||||
xml_register_callback(parse_strings);
|
||||
xml_register_callback(parse_messages);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue