diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index d44c7d6b4..5b23ef334 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -3628,9 +3628,19 @@ init_battle(region * r, battle **bp) /* Fehler: "Die Einheit ist mit uns alliert" */ if (calm_ct) { - variant var; - var.i = u2->faction->subscription; - if (curse_active(get_cursex(u->attribs, calm_ct, var, cmp_curseeffect_int))) { + attrib * a = a_find(u->attribs, &at_curse); + boolean calm = false; + while (a && a->type==&at_curse) { + curse * c = (curse *)a->data.v; + if (c->type==calm_ct && c->effect.i==u2->faction->subscription) { + if (curse_active(c)) { + calm = true; + break; + } + } + a = a->next; + } + if (calm) { cmistake(u, ord, 47, MSG_BATTLE); continue; } diff --git a/src/common/kernel/curse.c b/src/common/kernel/curse.c index 6d25bbe74..4a591f796 100644 --- a/src/common/kernel/curse.c +++ b/src/common/kernel/curse.c @@ -267,29 +267,6 @@ ct_find(const char *c) * einen pointer auf die struct zurück. */ -typedef struct cid { - int id; - int id2; -} twoids; - -boolean -cmp_curseeffect_vptr(const curse * c, variant var) -{ - return (c->effect.v==var.v); -} - -boolean -cmp_curseeffect_int(const curse * c, variant var) -{ - return (c->effect.i==var.i); -} - -boolean -cmp_cursedata_int(const curse * c, variant data) -{ - return (c->data.i==data.i); -} - boolean cmp_curse(const attrib * a, const void * data) { const curse * c = (const curse*)data; @@ -324,7 +301,7 @@ get_cursex(attrib *ap, const curse_type * ctype, variant data, boolean(*compare) curse * get_curse(attrib *ap, const curse_type * ctype) { - attrib * a = ap; + attrib * a = ap; while (a) { if (a->type->flags & ATF_CURSE) { const attrib_type * at = a->type; @@ -337,7 +314,6 @@ get_curse(attrib *ap, const curse_type * ctype) a = a->nexttype; } } - return NULL; } @@ -358,17 +334,6 @@ remove_curse(attrib **ap, const curse *c) if (a) a_remove(ap, a); } -void -remove_allcurse(attrib **ap, const void * data, boolean(*compare)(const attrib *, const void *)) -{ - attrib * a = a_select(*ap, data, compare); - while (a) { - attrib * next = a->next; - a_remove(ap, a); - a = a_select(next, data, compare); - } -} - /* gibt die allgemeine Stärke der Verzauberung zurück. id2 wird wie * oben benutzt. Dies ist nicht die Wirkung, sondern die Kraft und * damit der gegen Antimagie wirkende Widerstand einer Verzauberung */ diff --git a/src/common/kernel/curse.h b/src/common/kernel/curse.h index 8504e200d..8eeb381b5 100644 --- a/src/common/kernel/curse.h +++ b/src/common/kernel/curse.h @@ -311,9 +311,6 @@ extern int curse_age(struct attrib * a); extern boolean cmp_curse(const attrib * a, const void * data); extern boolean cmp_cursetype(const attrib * a, const void * data); -extern boolean cmp_curseeffect_vptr(const curse * c, variant data); -extern boolean cmp_curseeffect_int(const curse * c, variant data); -extern boolean cmp_cursedata_int(const curse * c, variant data); extern void * resolve_curse(variant data); extern boolean is_cursed_with(attrib *ap, curse *c); diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index c31efd978..67108299e 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -40,6 +40,7 @@ extern "C" { #define RF_MIGRATION (1<<10) #define RF_UNUSED_1 (1<<11) #define RF_ORCIFIED (1<<12) +#define RF_CURSED (1<<13) #define RF_COMBATDEBUG (1<<14) diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index 6400285ee..ec6d0be33 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -1067,6 +1067,8 @@ att_modification(const unit *u, skill_t sk) int result = 0; static boolean init = false; static const curse_type * skillmod_ct, * gbdream_ct, * worse_ct; + curse * c; + if (!init) { init = true; skillmod_ct = ct_find("skillmod"); @@ -1074,33 +1076,41 @@ att_modification(const unit *u, skill_t sk) worse_ct = ct_find("worse"); } - result += curse_geteffect(get_curse(u->attribs, worse_ct)); + c = get_curse(u->attribs, worse_ct); + if (c!=NULL) result += curse_geteffect(c); if (skillmod_ct) { - curse * c; - variant var; - var.i = sk; - c = get_cursex(u->attribs, skillmod_ct, var, cmp_cursedata_int); - result += curse_geteffect(c); + attrib * a = a_find(u->attribs, &at_curse); + while (a && a->type==&at_curse) { + curse * c = (curse *)a->data.v; + if (c->type==skillmod_ct && c->data.i==sk) { + result += curse_geteffect(c); + break; + } + a = a->next; + } } /* TODO hier kann nicht mit get/iscursed gearbeitet werden, da nur der * jeweils erste vom Typ C_GBDREAM zurückgegen wird, wir aber alle * durchsuchen und aufaddieren müssen */ - a = a_select(u->region->attribs, gbdream_ct, cmp_cursetype); - while (a) { + a = a_find(u->region->attribs, &at_curse); + while (a && a->type==&at_curse) { curse * c = (curse*)a->data.v; - int mod = curse_geteffect(c); - unit * mage = c->magician; - /* wir suchen jeweils den größten Bonus und den größten Malus */ - if (mod>0 && (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD))) - { - if (mod > bonus ) bonus = mod; - } else if (mod < 0 && - (mage == NULL || !alliedunit(mage, u->faction, HELP_GUARD))) - { - if (mod < malus ) malus = mod; - } - a = a_select(a->next, gbdream_ct, cmp_cursetype); + if (c->type==gbdream_ct) { + int mod = curse_geteffect(c); + unit * mage = c->magician; + /* wir suchen jeweils den größten Bonus und den größten Malus */ + if (mod>bonus) { + if (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD)) { + bonus = mod; + } + } else if (mod < malus) { + if (mage == NULL || !alliedunit(mage, u->faction, HELP_GUARD)) { + malus = mod; + } + } + } + a = a->next; } result = result + bonus + malus; diff --git a/src/common/spells/spells.c b/src/common/spells/spells.c index 3365639a4..27b365a2c 100644 --- a/src/common/spells/spells.c +++ b/src/common/spells/spells.c @@ -4066,10 +4066,6 @@ sp_rallypeasantmob(castorder *co) unit *mage = co->magician.u; int cast_level = co->level; - /* TODO - remove_allcurse(&r->attribs, C_RIOT, 0); - */ - for (u = r->units; u; u = un){ un = u->next; if (u->faction->no == MONSTER_FACTION && u->race == new_race[RC_PEASANT]){