diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index aca871429..62922c4aa 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -1843,7 +1843,7 @@ CRecruitmentWindow::CRecruitmentWindow(const CGDwelling *Dwelling, int Level, co max->block(true); slider->block(true); } - //buy->block(true); //not needed, will be blocked by initing slider on 0 + buy->block(true); } CRecruitmentWindow::~CRecruitmentWindow() diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index dc054e1c6..52aa900b9 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -1719,7 +1719,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, case 1: if(stack->owner == caster->getOwner()) { - if(battleIsImmune(player, spell, mode, stack->position) == SpellCasting::OK) + if(battleIsImmune(caster, spell, mode, stack->position) == SpellCasting::OK) { targetExists = true; break; @@ -1727,7 +1727,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, } break; case 0: - if(battleIsImmune(player, spell, mode, stack->position) == SpellCasting::OK) + if(battleIsImmune(caster, spell, mode, stack->position) == SpellCasting::OK) { targetExists = true; break; @@ -1736,7 +1736,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpell( int player, case -1: if(stack->owner != caster->getOwner()) { - if(battleIsImmune(player, spell, mode, stack->position) == SpellCasting::OK) + if(battleIsImmune(caster, spell, mode, stack->position) == SpellCasting::OK) { targetExists = true; break; @@ -1764,11 +1764,12 @@ SpellCasting::ESpellCastProblem BattleInfo::battleCanCastThisSpellHere( int play if(moreGeneralProblem != SpellCasting::OK) return moreGeneralProblem; - return battleIsImmune(player, spell, mode, dest); + return battleIsImmune(getHero(player), spell, mode, dest); } const CGHeroInstance * BattleInfo::getHero( int player ) const { + assert(sides[0] == player || sides[1] == player); if(heroes[0] && heroes[0]->getOwner() == player) return heroes[0]; @@ -1780,10 +1781,9 @@ bool NegateRemover(const Bonus* b) return b->source == Bonus::CREATURE_ABILITY; } -SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune( int player, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest ) const +SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest) const { const CStack * subject = getStackT(dest, false); - const CGHeroInstance * caster = mode == SpellCasting::HERO_CASTING ? getHero(player) : NULL; if(subject) { BonusList immunities = subject->getBonuses(Selector::type(Bonus::LEVEL_SPELL_IMMUNITY)); @@ -1819,7 +1819,7 @@ SpellCasting::ESpellCastProblem BattleInfo::battleIsImmune( int player, const CS else { if(spell->getTargetType() == CSpell::CREATURE || - (spell->getTargetType() == CSpell::CREATURE_EXPERT_MASSIVE && caster && caster->getSpellSchoolLevel(spell) < 3)) + (spell->getTargetType() == CSpell::CREATURE_EXPERT_MASSIVE && mode == SpellCasting::HERO_CASTING && caster && caster->getSpellSchoolLevel(spell) < 3)) { return SpellCasting::WRONG_SPELL_TARGET; } @@ -1833,7 +1833,7 @@ std::vector BattleInfo::calculateResistedStacks( const CSpell * sp, const std::vector ret; for(std::set::const_iterator it = affectedCreatures.begin(); it != affectedCreatures.end(); ++it) { - if(battleIsImmune(caster->getOwner(), sp, mode, (*it)->position) != SpellCasting::OK) + if(battleIsImmune(caster, sp, mode, (*it)->position) != SpellCasting::OK) { ret.push_back((*it)->ID); continue; diff --git a/lib/BattleState.h b/lib/BattleState.h index 31882cbb7..db13e2ab6 100644 --- a/lib/BattleState.h +++ b/lib/BattleState.h @@ -118,7 +118,7 @@ struct DLL_EXPORT BattleInfo : public CBonusSystemNode SpellCasting::ESpellCastProblem battleCanCastSpell(int player, SpellCasting::ECastingMode mode) const; //returns true if there are no general issues preventing from casting a spell SpellCasting::ESpellCastProblem battleCanCastThisSpell(int player, const CSpell * spell, SpellCasting::ECastingMode mode) const; //checks if given player can cast given spell - SpellCasting::ESpellCastProblem battleIsImmune(int player, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest) const; //checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into acount general problems such as not having spellbook or mana points etc. + SpellCasting::ESpellCastProblem battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest) const; //checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into acount general problems such as not having spellbook or mana points etc. SpellCasting::ESpellCastProblem battleCanCastThisSpellHere(int player, const CSpell * spell, SpellCasting::ECastingMode mode, THex dest); //checks if given player can cast given spell at given tile in given mode std::vector calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set affectedCreatures, int casterSideOwner, SpellCasting::ECastingMode mode) const;