forked from github/server
avoiding a_select some more, and removing the unused compare-functions
This commit is contained in:
parent
5c474b9eb7
commit
23247f1831
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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);
|
||||
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;
|
||||
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>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;
|
||||
if (mod>bonus) {
|
||||
if (mage==NULL || alliedunit(mage, u->faction, HELP_GUARD)) {
|
||||
bonus = mod;
|
||||
}
|
||||
a = a_select(a->next, gbdream_ct, cmp_cursetype);
|
||||
} else if (mod < malus) {
|
||||
if (mage == NULL || !alliedunit(mage, u->faction, HELP_GUARD)) {
|
||||
malus = mod;
|
||||
}
|
||||
}
|
||||
}
|
||||
a = a->next;
|
||||
}
|
||||
result = result + bonus + malus;
|
||||
|
||||
|
|
|
@ -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]){
|
||||
|
|
Loading…
Reference in New Issue