Browse Source

Allow cast avdmap spells without spellbook
* fixes http://bugs.vcmi.eu/view.php?id=1898
* partial fix for http://bugs.vcmi.eu/view.php?id=482
* fixes http://bugs.vcmi.eu/view.php?id=2155

AlexVinS 9 years ago
parent
commit
799b8519e0
2 changed files with 3 additions and 6 deletions
  1. 2 2
      lib/CBattleCallback.cpp
  2. 1 4
      lib/mapObjects/CGHeroInstance.cpp

+ 2 - 2
lib/CBattleCallback.cpp

@@ -377,8 +377,6 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastSpell(con
 
 			if(!hero)
 				return ESpellCastProblem::NO_HERO_TO_CAST_SPELL;
-			if(!hero->getArt(ArtifactPosition::SPELLBOOK))
-				return ESpellCastProblem::NO_SPELLBOOK;
 			if(hero->hasBonusOfType(Bonus::BLOCK_ALL_MAGIC))
 				return ESpellCastProblem::MAGIC_IS_BLOCKED;
 		}
@@ -1703,6 +1701,8 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 		{
 			const CGHeroInstance * castingHero = dynamic_cast<const CGHeroInstance *>(caster);//todo: unify hero|creature spell cost
 			assert(castingHero);
+			if(!castingHero->getArt(ArtifactPosition::SPELLBOOK))
+				return ESpellCastProblem::NO_SPELLBOOK;
 			if(!castingHero->canCastThisSpell(spell))
 				return ESpellCastProblem::HERO_DOESNT_KNOW_SPELL;
 			if(castingHero->mana < battleGetSpellCost(spell, castingHero)) //not enough mana

+ 1 - 4
lib/mapObjects/CGHeroInstance.cpp

@@ -974,12 +974,9 @@ void CGHeroInstance::getCastDescription(const CSpell * spell, const std::vector<
 
 bool CGHeroInstance::canCastThisSpell(const CSpell * spell) const
 {
-	if(nullptr == getArt(ArtifactPosition::SPELLBOOK))
-		return false;
-
 	const bool isAllowed = IObjectInterface::cb->isAllowed(0, spell->id);
 
-	const bool inSpellBook = vstd::contains(spells, spell->id);
+	const bool inSpellBook = vstd::contains(spells, spell->id) && nullptr != getArt(ArtifactPosition::SPELLBOOK);
 	const bool specificBonus = hasBonusOfType(Bonus::SPELL, spell->id);
 
 	bool schoolBonus = false;