AlexVinS 9 rokov pred
rodič
commit
7d2874bf12
1 zmenil súbory, kde vykonal 6 pridanie a 1 odobranie
  1. 6 1
      lib/CBattleCallback.cpp

+ 6 - 1
lib/CBattleCallback.cpp

@@ -1731,7 +1731,12 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 	case ECastingMode::HERO_CASTING:
 	case ECastingMode::HERO_CASTING:
 		{
 		{
 			const CGHeroInstance * castingHero = dynamic_cast<const CGHeroInstance *>(caster);//todo: unify hero|creature spell cost
 			const CGHeroInstance * castingHero = dynamic_cast<const CGHeroInstance *>(caster);//todo: unify hero|creature spell cost
-			assert(castingHero);
+			if(!castingHero)
+			{
+				logGlobal->error("battleCanCastThisSpell: invalid caster");
+				return ESpellCastProblem::INVALID;
+			}
+
 			if(!castingHero->getArt(ArtifactPosition::SPELLBOOK))
 			if(!castingHero->getArt(ArtifactPosition::SPELLBOOK))
 				return ESpellCastProblem::NO_SPELLBOOK;
 				return ESpellCastProblem::NO_SPELLBOOK;
 			if(!castingHero->canCastThisSpell(spell))
 			if(!castingHero->canCastThisSpell(spell))