Browse Source

Get rid of IBonusBearer::getEffect

AlexVinS 9 years ago
parent
commit
c243ae6f3e
3 changed files with 2 additions and 17 deletions
  1. 2 1
      lib/CBattleCallback.cpp
  2. 0 15
      lib/HeroBonus.cpp
  3. 0 1
      lib/HeroBonus.h

+ 2 - 1
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;
 	double multDefenceReduction = (100 - battleBonusValue (info.attackerBonuses, Selector::type(Bonus::ENEMY_DEFENCE_REDUCTION))) / 100.0;
 	attackDefenceDifference -= info.defenderBonuses->Defense() * multDefenceReduction;
 	attackDefenceDifference -= info.defenderBonuses->Defense() * multDefenceReduction;
 
 
-	if(const std::shared_ptr<Bonus> slayerEffect = info.attackerBonuses->getEffect(SpellID::SLAYER)) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT?
+	if(const std::shared_ptr<Bonus> slayerEffect = info.attackerBonuses->getBonus(Selector::type(Bonus::SLAYER))) //slayer handling //TODO: apply only ONLY_MELEE_FIGHT / DISTANCE_FIGHT?
 	{
 	{
 		std::vector<int> affectedIds;
 		std::vector<int> affectedIds;
 		int spLevel = slayerEffect->val;
 		int spLevel = slayerEffect->val;
 
 
+		//FIXME: do not check all creatures
 		for(int g = 0; g < VLC->creh->creatures.size(); ++g)
 		for(int g = 0; g < VLC->creh->creatures.size(); ++g)
 		{
 		{
 			for(const std::shared_ptr<Bonus> b : VLC->creh->creatures[g]->getBonusList())
 			for(const std::shared_ptr<Bonus> b : VLC->creh->creatures[g]->getBonusList())

+ 0 - 15
lib/HeroBonus.cpp

@@ -499,21 +499,6 @@ const TBonusListPtr IBonusBearer::getSpellBonuses() const
 	return getBonuses(selector, Selector::anyRange(), cachingStr.str());
 	return getBonuses(selector, Selector::anyRange(), cachingStr.str());
 }
 }
 
 
-const std::shared_ptr<Bonus> 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<Bonus> IBonusBearer::getBonus(const CSelector &selector) const
 const std::shared_ptr<Bonus> IBonusBearer::getBonus(const CSelector &selector) const
 {
 {
 	auto bonuses = getAllBonuses(Selector::all, Selector::all);
 	auto bonuses = getAllBonuses(Selector::all, Selector::all);

+ 0 - 1
lib/HeroBonus.h

@@ -604,7 +604,6 @@ public:
 	bool isLiving() const; //non-undead, non-non living or alive
 	bool isLiving() const; //non-undead, non-non living or alive
 	virtual si32 magicResistance() const;
 	virtual si32 magicResistance() const;
 	ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
 	ui32 Speed(int turn = 0, bool useBind = false) const; //get speed of creature with all modificators
-	const std::shared_ptr<Bonus> getEffect(ui16 id, int turn = 0) const; //effect id (SP)
 
 
 	si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)
 	si32 manaLimit() const; //maximum mana value for this hero (basically 10*knowledge)
 	int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;
 	int getPrimSkillLevel(PrimarySkill::PrimarySkill id) const;