diff --git a/lib/CBattleCallback.cpp b/lib/CBattleCallback.cpp index 2a235e168..4ff541cc0 100644 --- a/lib/CBattleCallback.cpp +++ b/lib/CBattleCallback.cpp @@ -950,11 +950,12 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c double multDefenceReduction = (100 - battleBonusValue (info.attackerBonuses, Selector::type(Bonus::ENEMY_DEFENCE_REDUCTION))) / 100.0; attackDefenceDifference -= info.defenderBonuses->Defense() * multDefenceReduction; - if(const std::shared_ptr slayerEffect = info.attackerBonuses->getEffect(SpellID::SLAYER)) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT? + if(const std::shared_ptr slayerEffect = info.attackerBonuses->getBonus(Selector::type(Bonus::SLAYER))) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT? { std::vector affectedIds; int spLevel = slayerEffect->val; + //FIXME: do not check all creatures for(int g = 0; g < VLC->creh->creatures.size(); ++g) { for(const std::shared_ptr b : VLC->creh->creatures[g]->getBonusList()) diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index 863b4e807..fe1e43354 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -499,21 +499,6 @@ const TBonusListPtr IBonusBearer::getSpellBonuses() const return getBonuses(selector, Selector::anyRange(), cachingStr.str()); } -const std::shared_ptr IBonusBearer::getEffect(ui16 id, int turn /*= 0*/) const -{ - //TODO should check only local bonuses? - auto bonuses = getAllBonuses(Selector::all, Selector::all); - for(auto & it : *bonuses) - { - if(it->source == Bonus::SPELL_EFFECT && it->sid == id) - { - if(!turn || it->turnsRemain > turn) - return it; - } - } - return nullptr; -} - const std::shared_ptr IBonusBearer::getBonus(const CSelector &selector) const { auto bonuses = getAllBonuses(Selector::all, Selector::all); diff --git a/lib/HeroBonus.h b/lib/HeroBonus.h index 3f6ac9874..9e3d01bb2 100644 --- a/lib/HeroBonus.h +++ b/lib/HeroBonus.h @@ -604,7 +604,6 @@ public: bool isLiving() const; //non-undead, non-non living or alive virtual si32 magicResistance() const; ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators - const std::shared_ptr getEffect(ui16 id, int turn = 0) const; //effect id (SP) si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge) int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;