Browse Source

Explicit use of limit selector in CBattleInfoCallback::getRandomBeneficialSpell
* reverted changes in IBonusBearer::hasBonusFrom just in case

AlexVinS 9 years ago
parent
commit
730e3b6d0f
2 changed files with 5 additions and 2 deletions
  1. 4 1
      lib/CBattleCallback.cpp
  2. 1 1
      lib/HeroBonus.cpp

+ 4 - 1
lib/CBattleCallback.cpp

@@ -1847,7 +1847,10 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c
 
 	for(const SpellID spellID : allPossibleSpells)
 	{
-		if (subject->hasBonusFrom(Bonus::SPELL_EFFECT, spellID)
+		std::stringstream cachingStr;
+		cachingStr << "source_" << Bonus::SPELL_EFFECT << "id_" << spellID.num;
+
+		if(subject->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellID), Selector::all, cachingStr.str())
 			//TODO: this ability has special limitations
 			|| battleCanCastThisSpellHere(subject, spellID.toSpell(), ECastingMode::CREATURE_ACTIVE_CASTING, subject->position) != ESpellCastProblem::OK)
 			continue;

+ 1 - 1
lib/HeroBonus.cpp

@@ -362,7 +362,7 @@ bool IBonusBearer::hasBonusFrom(Bonus::BonusSource source, ui32 sourceID) const
 {
 	std::stringstream cachingStr;
 	cachingStr << "source_" << source << "id_" << sourceID;
-	return hasBonus(Selector::source(source,sourceID), Selector::all, cachingStr.str());
+	return hasBonus(Selector::source(source,sourceID), cachingStr.str());
 }
 
 int IBonusBearer::MoraleVal() const