Browse Source

Get rid of IBonusBearer::getBonusesCount it had only one usage

AlexVinS 9 years ago
parent
commit
902117d812
3 changed files with 4 additions and 23 deletions
  1. 0 19
      lib/HeroBonus.cpp
  2. 0 3
      lib/HeroBonus.h
  3. 4 1
      lib/spells/AdventureSpellMechanics.cpp

+ 0 - 19
lib/HeroBonus.cpp

@@ -348,18 +348,6 @@ bool IBonusBearer::hasBonusOfType(Bonus::BonusType type, int subtype /*= -1*/) c
 	return hasBonus(s, cachingStr.str());
 }
 
-int IBonusBearer::getBonusesCount(Bonus::BonusSource from, int id) const
-{
-	std::stringstream cachingStr;
-	cachingStr << "source_" << from << "id_" << id;
-	return getBonusesCount(Selector::source(from, id), cachingStr.str());
-}
-
-int IBonusBearer::getBonusesCount(const CSelector &selector, const std::string &cachingStr /* =""*/) const
-{
-	return getBonuses(selector, cachingStr)->size();
-}
-
 const TBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const std::string &cachingStr /*= ""*/) const
 {
 	return getAllBonuses(selector, nullptr, nullptr, cachingStr);
@@ -1099,13 +1087,6 @@ bool NBonus::hasOfType(const CBonusSystemNode *obj, Bonus::BonusType type, int s
 	return false;
 }
 
-int NBonus::getCount(const CBonusSystemNode *obj, Bonus::BonusSource from, int id)
-{
-	if(obj)
-		return obj->getBonusesCount(from, id);
-	return 0;
-}
-
 const CSpell * Bonus::sourceSpell() const
 {
 	if(source == SPELL_EFFECT)

+ 0 - 3
lib/HeroBonus.h

@@ -579,7 +579,6 @@ public:
 	// * root is node on which call was made (nullptr will be replaced with this)
 	//interface
 	virtual const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr, const std::string &cachingStr = "") const = 0;
-	int getBonusesCount(const CSelector &selector, const std::string &cachingStr = "") const;
 	int valOfBonuses(const CSelector &selector, const std::string &cachingStr = "") const;
 	bool hasBonus(const CSelector &selector, const std::string &cachingStr = "") const;
 	bool hasBonus(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = "") const;
@@ -594,7 +593,6 @@ public:
 	int valOfBonuses(Bonus::BonusType type, int subtype = -1) const; //subtype -> subtype of bonus, if -1 then anyt;
 	bool hasBonusOfType(Bonus::BonusType type, int subtype = -1) const;//determines if hero has a bonus of given type (and optionally subtype)
 	bool hasBonusFrom(Bonus::BonusSource source, ui32 sourceID) const;
-	int getBonusesCount(Bonus::BonusSource from, int id) const;
 
 	//various hlp functions for non-trivial values
 	ui32 getMinDamage() const; //used for stacks and creatures only
@@ -720,7 +718,6 @@ namespace NBonus
 	//set of methods that may be safely called with nullptr objs
 	DLL_LINKAGE int valOf(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1); //subtype -> subtype of bonus, if -1 then any
 	DLL_LINKAGE bool hasOfType(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1);//determines if hero has a bonus of given type (and optionally subtype)
-	DLL_LINKAGE int getCount(const CBonusSystemNode *obj, Bonus::BonusSource from, int id);
 }
 
 /// generates HeroBonus from given data

+ 4 - 1
lib/spells/AdventureSpellMechanics.cpp

@@ -239,7 +239,10 @@ ESpellCastResult DimensionDoorMechanics::applyAdventureEffects(const SpellCastEn
 	const int schoolLevel = parameters.caster->getSpellSchoolLevel(owner);
 	const int movementCost = GameConstants::BASE_MOVEMENT_COST * ((schoolLevel >= 3) ? 2 : 3);
 
-	if(parameters.caster->getBonusesCount(Bonus::SPELL_EFFECT, SpellID::DIMENSION_DOOR) >= owner->getPower(schoolLevel)) //limit casts per turn
+	std::stringstream cachingStr;
+	cachingStr << "source_" << Bonus::SPELL_EFFECT << "id_" << owner->id.num;
+
+	if(parameters.caster->getBonuses(Selector::source(Bonus::SPELL_EFFECT, owner->id), Selector::all, cachingStr.str())->size() >= owner->getPower(schoolLevel)) //limit casts per turn
 	{
 		InfoWindow iw;
 		iw.player = parameters.caster->tempOwner;