Browse Source

Fixes crash on attempt to dynamic_cast AbilityCaster to Unit

Ivan Savenko 1 year ago
parent
commit
c0dc1040c2
1 changed files with 2 additions and 1 deletions
  1. 2 1
      lib/spells/effects/Heal.cpp

+ 2 - 1
lib/spells/effects/Heal.cpp

@@ -132,7 +132,8 @@ void Heal::prepareHealEffect(int64_t value, BattleUnitsChanged & pack, BattleLog
 			else if (unitHPgained > 0 && m->caster->getHeroCaster() == nullptr) //Show text about healed HP if healed by unit
 			else if (unitHPgained > 0 && m->caster->getHeroCaster() == nullptr) //Show text about healed HP if healed by unit
 			{
 			{
 				MetaString healText;
 				MetaString healText;
-				auto casterUnit = dynamic_cast<const battle::Unit*>(m->caster);
+				auto casterUnitID = m->caster->getCasterUnitId();
+				auto casterUnit = m->battle()->battleGetUnitByID(casterUnitID);
 				healText.appendLocalString(EMetaText::GENERAL_TXT, 414);
 				healText.appendLocalString(EMetaText::GENERAL_TXT, 414);
 				casterUnit->addNameReplacement(healText, false);
 				casterUnit->addNameReplacement(healText, false);
 				state->addNameReplacement(healText, false);
 				state->addNameReplacement(healText, false);