Even if equipment is not very frequently used, there's no need for it to use spell_list structs.

This commit is contained in:
Enno Rehling 2011-02-25 18:16:14 -08:00
parent fd2b30a0ff
commit b28fa19d01
2 changed files with 10 additions and 8 deletions

View file

@ -26,6 +26,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "race.h" #include "race.h"
/* util includes */ /* util includes */
#include <util/quicklist.h>
#include <util/rand.h> #include <util/rand.h>
#include <util/rng.h> #include <util/rng.h>
@ -89,7 +90,7 @@ void
equipment_addspell(equipment * eq, spell * sp) equipment_addspell(equipment * eq, spell * sp)
{ {
if (eq!=NULL) { if (eq!=NULL) {
spelllist_add(&eq->spells, sp); ql_set_insert(&eq->spells, sp);
} }
} }
@ -103,7 +104,7 @@ equipment_setitem(equipment * eq, const item_type * itype, const char * value)
idata = idata->next; idata = idata->next;
} }
if (idata==NULL) { if (idata==NULL) {
idata = malloc(sizeof(itemdata)); idata = (itemdata *)malloc(sizeof(itemdata));
idata->itype = itype; idata->itype = itype;
idata->value = strdup(value); idata->value = strdup(value);
idata->next = eq->items; idata->next = eq->items;
@ -141,15 +142,16 @@ equip_unit_mask(struct unit * u, const struct equipment * eq, int mask)
} }
if (mask&EQUIP_SPELLS) { if (mask&EQUIP_SPELLS) {
spell_list * sp = eq->spells; quicklist * ql = eq->spells;
if (sp!=NULL) { if (ql) {
sc_mage * m = get_mage(u); sc_mage * m = get_mage(u);
if (m==NULL) { if (m==NULL) {
assert(!"trying to equip spells on a non-mage!"); assert(!"trying to equip spells on a non-mage!");
} else { } else {
while (sp) { int qi;
add_spell(get_spelllist(m, u->faction), sp->data); for (qi=0;ql;ql_advance(&ql, &qi, 1)) {
sp = sp->next; spell * sp = (spell *)ql_get(ql, qi);
add_spell(get_spelllist(m, u->faction), sp);
} }
} }
} }

View file

@ -43,7 +43,7 @@ extern "C" {
char * name; char * name;
struct itemdata * items; struct itemdata * items;
char * skills[MAXSKILLS]; char * skills[MAXSKILLS];
struct spell_list * spells; struct quicklist * spells;
struct subset * subsets; struct subset * subsets;
struct equipment * next; struct equipment * next;
void (*callback)(const struct equipment *, struct unit *); void (*callback)(const struct equipment *, struct unit *);