From 73746893011f3fba5391b5114d147e7fe5ce16af Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Sun, 16 Jul 2017 00:01:33 +0300 Subject: [PATCH] Fixed https://bugs.vcmi.eu/view.php?id=2715 --- client/battle/CBattleInterface.cpp | 4 ++-- lib/battle/CBattleInfoCallback.cpp | 12 ++++++------ lib/spells/CSpellHandler.cpp | 2 +- lib/spells/CSpellHandler.h | 4 ++-- server/CGameHandler.cpp | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp index 882c03b5b..d40172abf 100644 --- a/client/battle/CBattleInterface.cpp +++ b/client/battle/CBattleInterface.cpp @@ -1649,7 +1649,7 @@ void CBattleInterface::enterCreatureCastingMode() { const ISpellCaster *caster = activeStack; const CSpell *spell = SpellID(creatureSpellToCast).toSpell(); - const bool isCastingPossible = (spell->canBeCastAt(curInt->cb.get(), caster, ECastingMode::CREATURE_ACTIVE_CASTING, BattleHex::INVALID) == ESpellCastProblem::OK); + const bool isCastingPossible = (spell->canBeCastAt(curInt->cb.get(), ECastingMode::CREATURE_ACTIVE_CASTING, caster, BattleHex::INVALID) == ESpellCastProblem::OK); if (isCastingPossible) { @@ -2499,7 +2499,7 @@ bool CBattleInterface::isCastingPossibleHere(const CStack *sactive, const CStack else { const ECastingMode::ECastingMode mode = creatureCasting ? ECastingMode::CREATURE_ACTIVE_CASTING : ECastingMode::HERO_CASTING; - isCastingPossible = (sp->canBeCastAt(curInt->cb.get(), caster, mode, myNumber) == ESpellCastProblem::OK); + isCastingPossible = (sp->canBeCastAt(curInt->cb.get(), mode, caster, myNumber) == ESpellCastProblem::OK); } } else diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 3e2de1467..06b8f2747 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -855,11 +855,11 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const //special battlefields with logically unavailable tiles std::vector impassableHexes; if(battleGetBattlefieldType().num == BFieldType::SHIP_TO_SHIP) - { - impassableHexes = - { + { + impassableHexes = + { 6, 7, 8, 9, - 24, 25, 26, + 24, 25, 26, 58, 59, 60, 75, 76, 77, 92, 93, 94, @@ -868,7 +868,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const 159, 160, 161, 162, 163, 176, 177, 178, 179, 180 }; - } + } for(auto hex : impassableHexes) ret[hex] = EAccessibility::UNAVAILABLE; @@ -1463,7 +1463,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(CRandomGenerator & rand, c if(subject->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellID), Selector::all, cachingStr.str()) //TODO: this ability has special limitations - || spellID.toSpell()->canBeCastAt(this, subject, ECastingMode::CREATURE_ACTIVE_CASTING, subject->position) != ESpellCastProblem::OK) + || spellID.toSpell()->canBeCast(this, ECastingMode::CREATURE_ACTIVE_CASTING, subject) != ESpellCastProblem::OK) continue; switch (spellID) diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index 924b5b222..cde1c0f97 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -399,7 +399,7 @@ void CSpell::getEffects(std::vector & lst, const int level, const bool cu } } -ESpellCastProblem::ESpellCastProblem CSpell::canBeCastAt(const CBattleInfoCallback * cb, const ISpellCaster * caster, ECastingMode::ECastingMode mode, BattleHex destination) const +ESpellCastProblem::ESpellCastProblem CSpell::canBeCastAt(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster, BattleHex destination) const { ESpellCastProblem::ESpellCastProblem problem = canBeCast(cb, mode, caster); if(problem != ESpellCastProblem::OK) diff --git a/lib/spells/CSpellHandler.h b/lib/spells/CSpellHandler.h index 73f57392e..3db133f4b 100644 --- a/lib/spells/CSpellHandler.h +++ b/lib/spells/CSpellHandler.h @@ -297,8 +297,8 @@ public: ///Checks general but spell-specific problems. Use only during battle. ESpellCastProblem::ESpellCastProblem canBeCast(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster) const; - ///checks for creature immunity / anything that prevent casting *at given hex* - doesn't take into account general problems such as not having spellbook or mana points etc. - ESpellCastProblem::ESpellCastProblem canBeCastAt(const CBattleInfoCallback * cb, const ISpellCaster * caster, ECastingMode::ECastingMode mode, BattleHex destination) const; + ///checks for creature immunity / anything that prevent casting *at given hex* + ESpellCastProblem::ESpellCastProblem canBeCastAt(const CBattleInfoCallback * cb, ECastingMode::ECastingMode mode, const ISpellCaster * caster, BattleHex destination) const; ///checks for creature immunity / anything that prevent casting *at given target* - doesn't take into account general problems such as not having spellbook or mana points etc. ESpellCastProblem::ESpellCastProblem isImmuneByStack(const ISpellCaster * caster, const CStack * obj) const; diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index bc4655e4b..dd4e085fd 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -5260,7 +5260,7 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta vstd::amin(chance, 100); const CSpell * spell = SpellID(spellID).toSpell(); - if(spell->canBeCastAt(gs->curB, attacker, ECastingMode::AFTER_ATTACK_CASTING, oneOfAttacked->position) != ESpellCastProblem::OK) + if(spell->canBeCastAt(gs->curB, ECastingMode::AFTER_ATTACK_CASTING, attacker, oneOfAttacked->position) != ESpellCastProblem::OK) continue; //check if spell should be cast (probability handling)