From 27ba4f10be65558c9d0911e5d35a3c700a19cd79 Mon Sep 17 00:00:00 2001 From: Kris-Ja <107918765+Kris-Ja@users.noreply.github.com> Date: Mon, 25 Mar 2024 23:17:23 +0100 Subject: [PATCH] Fix BonusLimitEffect #3070 Change BonusList::getBonus() to return bonuses with any BonusLimitEffect by default (returned only bonuses with BonusLimitEffect::NO_LIMIT previously) --- lib/bonuses/Bonus.h | 2 +- lib/bonuses/BonusList.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/bonuses/Bonus.h b/lib/bonuses/Bonus.h index 2ed8225b5..b32bfde2c 100644 --- a/lib/bonuses/Bonus.h +++ b/lib/bonuses/Bonus.h @@ -70,7 +70,7 @@ struct DLL_LINKAGE Bonus : public std::enable_shared_from_this<Bonus> std::string stacking; // bonuses with the same stacking value don't stack (e.g. Angel/Archangel morale bonus) CAddInfo additionalInfo; - BonusLimitEffect effectRange = BonusLimitEffect::NO_LIMIT; //if not NO_LIMIT, bonus will be omitted by default + BonusLimitEffect effectRange = BonusLimitEffect::NO_LIMIT; TLimiterPtr limiter; TPropagatorPtr propagator; diff --git a/lib/bonuses/BonusList.cpp b/lib/bonuses/BonusList.cpp index 752335044..ee6b2b64e 100644 --- a/lib/bonuses/BonusList.cpp +++ b/lib/bonuses/BonusList.cpp @@ -190,9 +190,7 @@ void BonusList::getBonuses(BonusList & out, const CSelector &selector, const CSe out.reserve(bonuses.size()); for(const auto & b : bonuses) { - //add matching bonuses that matches limit predicate or have NO_LIMIT if no given predicate - auto noFightLimit = b->effectRange == BonusLimitEffect::NO_LIMIT; - if(selector(b.get()) && ((!limit && noFightLimit) || ((bool)limit && limit(b.get())))) + if(selector(b.get()) && (!limit || ((bool)limit && limit(b.get())))) out.push_back(b); } }