mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
Fix crash on stack being affected by spell with battle-wide propagator
This commit is contained in:
@@ -686,7 +686,12 @@ void StackInfoBasicPanel::initializeData(const CStack * stack)
|
||||
if (hasGraphics)
|
||||
{
|
||||
//FIXME: support permanent duration
|
||||
int duration = stack->getFirstBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(effect)))->turnsRemain;
|
||||
auto spellBonuses = stack->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(effect)));
|
||||
|
||||
if (spellBonuses->empty())
|
||||
throw std::runtime_error("Failed to find effects for spell " + effect.toSpell()->getJsonKey());
|
||||
|
||||
int duration = spellBonuses->front()->duration;
|
||||
|
||||
icons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SpellInt"), effect + 1, 0, firstPos.x + offset.x * printed, firstPos.y + offset.y * printed));
|
||||
if(settings["general"]["enableUiEnhancements"].Bool())
|
||||
|
@@ -234,7 +234,11 @@ CStackWindow::ActiveSpellsSection::ActiveSpellsSection(CStackWindow * owner, int
|
||||
spellText = CGI->generaltexth->allTexts[610]; //"%s, duration: %d rounds."
|
||||
boost::replace_first(spellText, "%s", spell->getNameTranslated());
|
||||
//FIXME: support permanent duration
|
||||
int duration = battleStack->getFirstBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(effect)))->turnsRemain;
|
||||
auto spellBonuses = battleStack->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(effect)));
|
||||
if (spellBonuses->empty())
|
||||
throw std::runtime_error("Failed to find effects for spell " + effect.toSpell()->getJsonKey());
|
||||
|
||||
int duration = spellBonuses->front()->duration;
|
||||
boost::replace_first(spellText, "%d", std::to_string(duration));
|
||||
|
||||
spellIcons.push_back(std::make_shared<CAnimImage>(AnimationPath::builtin("SpellInt"), effect + 1, 0, firstPos.x + offset.x * printed, firstPos.y + offset.y * printed));
|
||||
|
Reference in New Issue
Block a user