diff --git a/src/common/kernel/curse.c b/src/common/kernel/curse.c index db0d65ef0..abdee24be 100644 --- a/src/common/kernel/curse.c +++ b/src/common/kernel/curse.c @@ -109,13 +109,19 @@ int curse_age(attrib * a) { curse * c = (curse*)a->data.v; + int result = 0; - if (c->flag & CURSE_NOAGE) { + if (c->type->age) { + result = c->type->age(c); + } + if (result!=0) { + c->duration = 0; + } else if (c->flag & CURSE_NOAGE) { c->duration = 1; } else { c->duration = max(0, c->duration-1); } - return (c->duration); + return c->duration; } void diff --git a/src/common/kernel/curse.h b/src/common/kernel/curse.h index 2480d5d8d..46d032e3f 100644 --- a/src/common/kernel/curse.h +++ b/src/common/kernel/curse.h @@ -227,6 +227,7 @@ typedef struct curse_type { int (*read)(FILE * F, curse * c); int (*write)(FILE * F, const curse * c); int (*cansee)(const struct faction*, const void*, typ_t, curse *, int); + int (*age)(curse *); } curse_type; diff --git a/src/common/kernel/magic.h b/src/common/kernel/magic.h index 164a1e8e2..dd47949c4 100644 --- a/src/common/kernel/magic.h +++ b/src/common/kernel/magic.h @@ -226,7 +226,6 @@ void magic(void); void regeneration_magiepunkte(void); -extern attrib_type at_deathcloud; extern attrib_type at_seenspell; extern attrib_type at_mage; extern attrib_type at_familiarmage; diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 78e73b5c5..7bee58638 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -3182,35 +3182,10 @@ sp_unholypower(castorder *co) * (FARCASTING | REGIONSPELL | TESTRESISTANCE) */ -static struct curse_type ct_deathcloud = { - "deathcloud", CURSETYP_REGION, 0, NO_MERGE, NULL, cinfo_region, -}; - -static curse * -mk_deathcloud(unit * mage, region * r, double force, int duration) -{ - variant effect; - curse * c; - - effect.f = (float)force/2; - c = create_curse(mage, &r->attribs, &ct_deathcloud, force, duration, effect, 0); - c->data.v = r; - return c; -} - -static void -dc_finalize(struct attrib * a) -{ - curse * c = (curse*)a->data.v; - c->data.v = NULL; - destroy_curse(c); -} - static int -dc_age(struct attrib * a) +dc_age(struct curse * c) /* age returns 0 if the attribute needs to be removed, !=0 otherwise */ { - curse * c = (curse*)a->data.v; region * r = (region*)c->data.v; unit ** up = &r->units; unit * mage = c->magician; @@ -3251,14 +3226,25 @@ dc_age(struct attrib * a) "mage region", mage, r)); } - return --c->duration; + return 0; } - -attrib_type at_deathcloud = { - "curse_dc", curse_init, curse_done, dc_age, curse_write, curse_read, ATF_CURSE +static struct curse_type ct_deathcloud = { + "deathcloud", CURSETYP_REGION, 0, NO_MERGE, NULL, cinfo_region, NULL, NULL, NULL, NULL, dc_age }; +static curse * +mk_deathcloud(unit * mage, region * r, double force, int duration) +{ + variant effect; + curse * c; + + effect.f = (float)force/2; + c = create_curse(mage, &r->attribs, &ct_deathcloud, force, duration, effect, 0); + c->data.v = r; + return c; +} + #define COMPAT_DEATHCLOUD #ifdef COMPAT_DEATHCLOUD static int