From ad4602064fd6f3c5a6411545466ee4db83bb941b Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 9 Apr 2022 00:12:02 +0300 Subject: [PATCH 19/19] Make effect_cumulative_max|min() to consider always-active opposite effects See osdn #44303 Signed-off-by: Marko Lindqvist --- common/effects.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/common/effects.c b/common/effects.c index d018ff8721..dfca083eb9 100644 --- a/common/effects.c +++ b/common/effects.c @@ -315,10 +315,15 @@ int effect_cumulative_max(enum effect_type type, struct universal *for_uni) if (plist) { effect_list_iterate(plist, peffect) { - if (peffect->type == type && peffect->value > 0) { - if (for_uni == NULL - || universal_fulfills_requirements(FALSE, &(peffect->reqs), - for_uni)) { + if (peffect->type == type) { + if (peffect->value > 0) { + if (for_uni == NULL + || universal_fulfills_requirements(FALSE, &(peffect->reqs), + for_uni)) { + value += peffect->value; + } + } else if (requirement_vector_size(&peffect->reqs) == 0) { + /* Always active negative effect */ value += peffect->value; } } @@ -342,10 +347,15 @@ int effect_cumulative_min(enum effect_type type, struct universal *for_uni) if (plist) { effect_list_iterate(plist, peffect) { - if (peffect->type == type && peffect->value < 0) { - if (for_uni == NULL - || universal_fulfills_requirements(FALSE, &(peffect->reqs), - for_uni)) { + if (peffect->type == type) { + if (peffect->value < 0) { + if (for_uni == NULL + || universal_fulfills_requirements(FALSE, &(peffect->reqs), + for_uni)) { + value += peffect->value; + } + } else if (requirement_vector_size(&peffect->reqs) == 0) { + /* Always active positive effect */ value += peffect->value; } } -- 2.35.1