From 65744fee76d2478c205f58924daa5e6a04e19fb7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 6 Mar 2004 17:41:49 +0000 Subject: [PATCH] duplicate attribute, mage --- src/common/kernel/magic.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/kernel/magic.c b/src/common/kernel/magic.c index c1c08ca1e..0ecb7d8cd 100644 --- a/src/common/kernel/magic.c +++ b/src/common/kernel/magic.c @@ -318,7 +318,15 @@ create_mage(unit * u, magic_t mtyp) attrib *a; int i; - mage = calloc(1, sizeof(sc_mage)); + a = a_find(u->attribs, &at_mage); + if (a==NULL) { + a = a_add(&u->attribs, a_new(&at_mage)); + mage = calloc(1, sizeof(sc_mage)); + a->data.v = mage; + } else { + mage = a->data.v; + assert(mage->magietyp == mtyp); + } mage->magietyp = mtyp; mage->spellpoints = 0; @@ -328,8 +336,6 @@ create_mage(unit * u, magic_t mtyp) mage->combatspell[i] = SPL_NOSPELL; } mage->spellptr = NULL; - a = a_add(&u->attribs, a_new(&at_mage)); - a->data.v = mage; createspelllist(u, mtyp); return mage; }