1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Workaround - check also for valueType when updating bonuses

We should not assume that spells always have a single bonus with same
type/subtype
This commit is contained in:
Ivan Savenko 2024-05-28 17:01:30 +00:00
parent 28081085a8
commit 58b1e74342

View File

@ -930,7 +930,7 @@ uint32_t BattleInfo::nextUnitId() const
void BattleInfo::addOrUpdateUnitBonus(CStack * sta, const Bonus & value, bool forceAdd)
{
if(forceAdd || !sta->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, value.sid).And(Selector::typeSubtype(value.type, value.subtype))))
if(forceAdd || !sta->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, value.sid).And(Selector::typeSubtypeValueType(value.type, value.subtype, value.valType))))
{
//no such effect or cumulative - add new
logBonus->trace("%s receives a new bonus: %s", sta->nodeName(), value.Description());
@ -942,7 +942,7 @@ void BattleInfo::addOrUpdateUnitBonus(CStack * sta, const Bonus & value, bool fo
for(const auto & stackBonus : sta->getExportedBonusList()) //TODO: optimize
{
if(stackBonus->source == value.source && stackBonus->sid == value.sid && stackBonus->type == value.type && stackBonus->subtype == value.subtype)
if(stackBonus->source == value.source && stackBonus->sid == value.sid && stackBonus->type == value.type && stackBonus->subtype == value.subtype && stackBonus->valType == value.valType)
{
stackBonus->turnsRemain = std::max(stackBonus->turnsRemain, value.turnsRemain);
}