forked from github/server
filter by curse-type before trying to call update_gbdreams.
This commit is contained in:
parent
b5ed7c562d
commit
d99ffaf1ed
|
@ -1274,18 +1274,16 @@ static int item_modification(const unit * u, skill_t sk, int val)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int update_gbdream(const unit * u, int bonus, curse *c, const curse_type *gbdream_ct, int sign){
|
static int update_gbdream(const unit * u, int bonus, curse *c, int sign) {
|
||||||
if (curse_active(c) && c->type == gbdream_ct) {
|
double effect = curse_geteffect(c);
|
||||||
double effect = curse_geteffect(c);
|
unit *mage = c->magician;
|
||||||
unit *mage = c->magician;
|
/* wir suchen jeweils den groessten Bonus und den groessten Malus */
|
||||||
/* wir suchen jeweils den groessten Bonus und den groessten Malus */
|
if (sign * effect > sign * bonus) {
|
||||||
if (sign * effect > sign * bonus) {
|
bool allied;
|
||||||
bool allied;
|
assert(mage && mage->number > 0);
|
||||||
assert(mage && mage->number > 0);
|
allied = alliedunit(mage, u->faction, HELP_GUARD);
|
||||||
allied = alliedunit(mage, u->faction, HELP_GUARD);
|
if ((sign>0)?allied:!allied) {
|
||||||
if ((sign>0)?allied:!allied) {
|
bonus = (int)effect;
|
||||||
bonus = (int)effect;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return bonus;
|
return bonus;
|
||||||
|
@ -1294,7 +1292,7 @@ static int update_gbdream(const unit * u, int bonus, curse *c, const curse_type
|
||||||
int att_modification(const unit * u, skill_t sk)
|
int att_modification(const unit * u, skill_t sk)
|
||||||
{
|
{
|
||||||
double result = 0;
|
double result = 0;
|
||||||
static bool init = false;
|
static bool init = false; // TODO: static variables are bad global state
|
||||||
static const curse_type *skillmod_ct, *gbdream_ct, *worse_ct;
|
static const curse_type *skillmod_ct, *gbdream_ct, *worse_ct;
|
||||||
curse *c;
|
curse *c;
|
||||||
|
|
||||||
|
@ -1329,9 +1327,11 @@ int att_modification(const unit * u, skill_t sk)
|
||||||
while (a && a->type == &at_curse) {
|
while (a && a->type == &at_curse) {
|
||||||
curse *c = (curse *)a->data.v;
|
curse *c = (curse *)a->data.v;
|
||||||
|
|
||||||
assert(c->magician); // update_gbdream makes no sense if there is no caster (calls alliedunit)
|
if (curse_active(c) && c->type == gbdream_ct) {
|
||||||
bonus = update_gbdream(u, bonus, c, gbdream_ct, 1);
|
assert(c->magician); // update_gbdream makes no sense if there is no caster (calls alliedunit)
|
||||||
malus = update_gbdream(u, malus, c, gbdream_ct, -1);
|
bonus = update_gbdream(u, bonus, c, 1);
|
||||||
|
malus = update_gbdream(u, malus, c, -1);
|
||||||
|
}
|
||||||
a = a->next;
|
a = a->next;
|
||||||
}
|
}
|
||||||
result = result + bonus + malus;
|
result = result + bonus + malus;
|
||||||
|
|
Loading…
Reference in New Issue