瀏覽代碼

Merge pull request #5948 from Opuszek/fix_segmentation_fault

Fixes segmentation fault when getting magic strength of a hero
Ivan Savenko 2 月之前
父節點
當前提交
76aa075d10
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      AI/Nullkiller/Analyzers/HeroManager.cpp

+ 4 - 0
AI/Nullkiller/Analyzers/HeroManager.cpp

@@ -221,6 +221,10 @@ float HeroManager::getMagicStrength(const CGHeroInstance * hero) const
 	for(auto spellId : hero->getSpellsInSpellbook())
 	{
 		auto spell = spellId.toSpell();
+
+		if (!spell->isAdventure())
+			continue;
+
 		auto schoolLevel = hero->getSpellSchoolLevel(spell);
 		auto townPortalEffect = spell->getAdventureMechanics().getEffectAs<TownPortalEffect>(hero);