From bb69ab1a1a36f6dbdc3c99208f7ab77ed3ca0ae7 Mon Sep 17 00:00:00 2001 From: Dydzio Date: Sun, 22 Sep 2024 18:25:18 +0200 Subject: [PATCH] Fix assert and condition for counting spell hexes --- client/CPlayerInterface.cpp | 2 +- client/battle/BattleActionsController.cpp | 2 +- lib/battle/CBattleInfoCallback.cpp | 4 ++-- lib/spells/effects/UnitEffect.cpp | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 162aada4c..57eb5b29e 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -937,7 +937,7 @@ void CPlayerInterface::battleAttack(const BattleID & battleID, const BattleAttac info.secondaryDefender.push_back(cb->getBattle(battleID)->battleGetStackByID(elem.stackAttacked)); } } - assert(info.defender != nullptr); + assert(info.defender != nullptr || (info.spellEffect != SpellID::NONE && info.indirectAttack)); assert(info.attacker != nullptr); battleInt->stackAttacking(info); diff --git a/client/battle/BattleActionsController.cpp b/client/battle/BattleActionsController.cpp index 82972ab6a..a0c8eaa76 100644 --- a/client/battle/BattleActionsController.cpp +++ b/client/battle/BattleActionsController.cpp @@ -532,7 +532,7 @@ std::string BattleActionsController::actionGetStatusMessage(PossiblePlayerBattle if(targetStack == nullptr) //should be true only for spell-like attack { auto spellLikeAttackBonus = owner.stacksController->getActiveStack()->getBonus(Selector::type()(BonusType::SPELL_LIKE_ATTACK)); - assert(bonus != nullptr); + assert(spellLikeAttackBonus != nullptr); return boost::str(boost::format(CGI->generaltexth->allTexts[26]) % spellLikeAttackBonus->subtype.as().toSpell()->getNameTranslated()); } diff --git a/lib/battle/CBattleInfoCallback.cpp b/lib/battle/CBattleInfoCallback.cpp index 1f76a85fd..421752d68 100644 --- a/lib/battle/CBattleInfoCallback.cpp +++ b/lib/battle/CBattleInfoCallback.cpp @@ -740,8 +740,8 @@ bool CBattleInfoCallback::battleCanTargetEmptyHex(const battle::Unit * attacker) if(spell->isDamage()) { spells::BattleCast cast(this, attacker, spells::Mode::SPELL_LIKE_ATTACK, spell); - - if(vstd::find(spell->battleMechanics(&cast)->getTargetTypes(), spells::AimType::LOCATION) != spell->battleMechanics(&cast)->getTargetTypes().end()) + BattleHex dummySpellTarget = BattleHex(50); //check arbitrary hex for general spell range since currently there is no general way to access amount of hexes + if(spell->battleMechanics(&cast)->rangeInHexes(dummySpellTarget).size() > 1) { return true; } diff --git a/lib/spells/effects/UnitEffect.cpp b/lib/spells/effects/UnitEffect.cpp index a56767d24..657f98e9f 100644 --- a/lib/spells/effects/UnitEffect.cpp +++ b/lib/spells/effects/UnitEffect.cpp @@ -164,6 +164,7 @@ EffectTarget UnitEffect::transformTargetByRange(const Mechanics * m, const Targe if(m->alwaysHitFirstTarget()) { + //TODO: examine if adjustments needed related to INVINCIBLE bonus if(!aimPoint.empty() && aimPoint.front().unitValue) targets.insert(aimPoint.front().unitValue); }