1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix crash on broken ENCHANTED bonus

This commit is contained in:
Ivan Savenko 2024-02-05 21:07:01 +02:00
parent 9e5e7d95c3
commit a97d1d9377

View File

@ -584,10 +584,10 @@ void BattleFlowProcessor::stackEnchantedTrigger(const CBattleInfoCallback & batt
auto bl = *(st->getBonuses(Selector::type()(BonusType::ENCHANTED)));
for(auto b : bl)
{
const CSpell * sp = b->subtype.as<SpellID>().toSpell();
if(!sp)
if (!b->subtype.as<SpellID>().hasValue())
continue;
const CSpell * sp = b->subtype.as<SpellID>().toSpell();
const int32_t val = bl.valOfBonuses(Selector::typeSubtype(b->type, b->subtype));
const int32_t level = ((val > 3) ? (val - 3) : val);