From 27efe157a671eee5216d62228902021cd8fcf270 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 9 Apr 2022 00:07:19 +0300 Subject: [PATCH 45/45] Make effect_cumulative_max|min() to consider always-active opposite effects See osdn #44303 Signed-off-by: Marko Lindqvist --- common/effects.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/common/effects.c b/common/effects.c index 11ba70ab54..c208cd1228 100644 --- a/common/effects.c +++ b/common/effects.c @@ -333,9 +333,14 @@ int effect_cumulative_max(enum effect_type type, struct universal *unis, if (plist) { effect_list_iterate(plist, peffect) { - if (peffect->type == type && peffect->value > 0) { - if (unis == NULL - || !universals_mean_unfulfilled(&(peffect->reqs), unis, n_unis)) { + if (peffect->type == type) { + if (peffect->value > 0) { + if (unis == NULL + || !universals_mean_unfulfilled(&(peffect->reqs), unis, n_unis)) { + value += peffect->value; + } + } else if (requirement_vector_size(&peffect->reqs) == 0) { + /* Always active negative effect */ value += peffect->value; } } @@ -359,10 +364,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