Explorar o código

Remove strange & unused double-selector logic

Ivan Savenko hai 3 meses
pai
achega
1e3e2f665c
Modificáronse 39 ficheiros con 71 adicións e 85 borrados
  1. 4 5
      AI/BattleAI/StackWithBonuses.cpp
  2. 1 2
      AI/BattleAI/StackWithBonuses.h
  3. 1 1
      AI/Nullkiller/AIUtility.cpp
  4. 2 2
      client/ClientCommandManager.cpp
  5. 1 1
      client/battle/BattleStacksController.cpp
  6. 1 1
      client/windows/CCreatureWindow.cpp
  7. 1 1
      lib/CCreatureHandler.cpp
  8. 1 1
      lib/CStack.cpp
  9. 1 1
      lib/battle/CBattleInfoCallback.cpp
  10. 3 3
      lib/battle/CUnitState.cpp
  11. 1 1
      lib/battle/CUnitState.h
  12. 1 1
      lib/battle/DamageCalculator.cpp
  13. 3 4
      lib/bonuses/BonusList.cpp
  14. 1 1
      lib/bonuses/BonusList.h
  15. 9 9
      lib/bonuses/CBonusSystemNode.cpp
  16. 2 2
      lib/bonuses/CBonusSystemNode.h
  17. 3 13
      lib/bonuses/IBonusBearer.cpp
  18. 1 3
      lib/bonuses/IBonusBearer.h
  19. 1 1
      lib/spells/AdventureSpellMechanics.cpp
  20. 8 7
      scripting/lua/api/BonusSystem.cpp
  21. 2 2
      test/battle/CBattleInfoCallbackTest.cpp
  22. 2 2
      test/battle/CHealthTest.cpp
  23. 2 2
      test/mock/BattleFake.cpp
  24. 2 2
      test/mock/mock_BonusBearer.cpp
  25. 1 1
      test/mock/mock_BonusBearer.h
  26. 1 1
      test/mock/mock_battle_Unit.h
  27. 3 3
      test/spells/AbilityCasterTest.cpp
  28. 1 1
      test/spells/targetConditions/AbsoluteLevelConditionTest.cpp
  29. 1 1
      test/spells/targetConditions/AbsoluteSpellConditionTest.cpp
  30. 1 1
      test/spells/targetConditions/BonusConditionTest.cpp
  31. 1 1
      test/spells/targetConditions/CreatureConditionTest.cpp
  32. 1 1
      test/spells/targetConditions/ElementalConditionTest.cpp
  33. 1 1
      test/spells/targetConditions/HealthValueConditionTest.cpp
  34. 1 1
      test/spells/targetConditions/ImmunityNegationConditionTest.cpp
  35. 1 1
      test/spells/targetConditions/NormalLevelConditionTest.cpp
  36. 1 1
      test/spells/targetConditions/NormalSpellConditionTest.cpp
  37. 1 1
      test/spells/targetConditions/ReceptiveFeatureConditionTest.cpp
  38. 1 1
      test/spells/targetConditions/SpellEffectConditionTest.cpp
  39. 1 1
      test/spells/targetConditions/TargetConditionItemFixture.h

+ 4 - 5
AI/BattleAI/StackWithBonuses.cpp

@@ -133,11 +133,10 @@ SlotID StackWithBonuses::unitSlot() const
 	return slot;
 }
 
-TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, const CSelector & limit,
-	const std::string & cachingStr) const
+TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, const std::string & cachingStr) const
 {
 	auto ret = std::make_shared<BonusList>();
-	TConstBonusListPtr originalList = origBearer->getAllBonuses(selector, limit, cachingStr);
+	TConstBonusListPtr originalList = origBearer->getAllBonuses(selector, cachingStr);
 
 	vstd::copy_if(*originalList, std::back_inserter(*ret), [this](const std::shared_ptr<Bonus> & b)
 	{
@@ -147,7 +146,7 @@ TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, c
 
 	for(const Bonus & bonus : bonusesToUpdate)
 	{
-		if(selector(&bonus) && (!limit || limit(&bonus)))
+		if(selector(&bonus))
 		{
 			if(ret->getFirst(Selector::source(BonusSource::SPELL_EFFECT, bonus.sid).And(Selector::typeSubtype(bonus.type, bonus.subtype))))
 			{
@@ -164,7 +163,7 @@ TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, c
 	for(auto & bonus : bonusesToAdd)
 	{
 		auto b = std::make_shared<Bonus>(bonus);
-		if(selector(b.get()) && (!limit || !limit(b.get())))
+		if(selector(b.get()))
 			ret->push_back(b);
 	}
 	//TODO limiters?

+ 1 - 2
AI/BattleAI/StackWithBonuses.h

@@ -90,8 +90,7 @@ public:
 	SlotID unitSlot() const override;
 
 	///IBonusBearer
-	TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit,
-		const std::string & cachingStr = "") const override;
+	TConstBonusListPtr getAllBonuses(const CSelector & selector, const std::string & cachingStr = "") const override;
 
 	int32_t getTreeVersion() const override;
 

+ 1 - 1
AI/Nullkiller/AIUtility.cpp

@@ -290,7 +290,7 @@ double getArtifactBonusRelevance(const CGHeroInstance * hero, const std::shared_
 
 		for (const auto & slot : hero->Slots())
 		{
-			const auto allBonuses = slot.second->getAllBonuses(Selector::all, Selector::all);
+			const auto allBonuses = slot.second->getAllBonuses(Selector::all);
 			BonusLimitationContext context = {*bonus, *slot.second, *allBonuses, stillUndecided};
 
 			uint64_t unitStrength = slot.second->getPower();

+ 2 - 2
client/ClientCommandManager.cpp

@@ -440,14 +440,14 @@ void ClientCommandManager::handleBonusesCommand(std::istringstream & singleWordB
 		return ss.str();
 	};
 		printCommandMessage("Bonuses of " + GAME->interface()->localState->getCurrentArmy()->getObjectName() + "\n");
-		printCommandMessage(format(*GAME->interface()->localState->getCurrentArmy()->getAllBonuses(Selector::all, Selector::all)) + "\n");
+		printCommandMessage(format(*GAME->interface()->localState->getCurrentArmy()->getAllBonuses(Selector::all)) + "\n");
 
 	printCommandMessage("\nInherited bonuses:\n");
 	TCNodes parents;
 		GAME->interface()->localState->getCurrentArmy()->getParents(parents);
 	for(const CBonusSystemNode *parent : parents)
 	{
-		printCommandMessage(std::string("\nBonuses from ") + typeid(*parent).name() + "\n" + format(*parent->getAllBonuses(Selector::all, Selector::all)) + "\n");
+		printCommandMessage(std::string("\nBonuses from ") + typeid(*parent).name() + "\n" + format(*parent->getAllBonuses(Selector::all)) + "\n");
 	}
 }
 

+ 1 - 1
client/battle/BattleStacksController.cpp

@@ -805,7 +805,7 @@ void BattleStacksController::removeExpiredColorFilters()
 	{
 		if (!filter.persistent)
 		{
-			if (filter.source && !filter.target->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(filter.source->id)), Selector::all))
+			if (filter.source && !filter.target->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(filter.source->id))))
 				return true;
 			if (filter.effectColor == Colors::TRANSPARENCY && filter.transparency == 255)
 				return true;

+ 1 - 1
client/windows/CCreatureWindow.cpp

@@ -848,7 +848,7 @@ void CStackWindow::init()
 
 void CStackWindow::initBonusesList()
 {
-	BonusList receivedBonuses = *info->stackNode->getBonuses(CSelector(Bonus::Permanent), Selector::all);
+	BonusList receivedBonuses = *info->stackNode->getBonuses(CSelector(Bonus::Permanent));
 	BonusList abilities = info->creature->getExportedBonusList();
 
 	// remove all bonuses that are not propagated away

+ 1 - 1
lib/CCreatureHandler.cpp

@@ -329,7 +329,7 @@ void CCreature::addBonus(int val, BonusType type, BonusSubtypeID subtype)
 	BonusList & exported = getExportedBonusList();
 
 	BonusList existing;
-	exported.getBonuses(existing, selector, Selector::all);
+	exported.getBonuses(existing, selector);
 
 	if(existing.empty())
 	{

+ 1 - 1
lib/CStack.cpp

@@ -134,7 +134,7 @@ std::vector<SpellID> CStack::activeSpells() const
 		return b->type != BonusType::NONE && b->sid.as<SpellID>().toSpell() && !b->sid.as<SpellID>().toSpell()->isAdventure();
 	}));
 
-	TConstBonusListPtr spellEffects = getBonuses(selector, Selector::all, cachingStr.str());
+	TConstBonusListPtr spellEffects = getBonuses(selector, cachingStr.str());
 	for(const auto & it : *spellEffects)
 	{
 		if(!vstd::contains(ret, it->sid.as<SpellID>()))  //do not duplicate spells with multiple effects

+ 1 - 1
lib/battle/CBattleInfoCallback.cpp

@@ -1797,7 +1797,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(vstd::RNG & rand, const ba
 		std::stringstream cachingStr;
 		cachingStr << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT) << "id_" << spellID.num;
 
-		if(subject->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(spellID)), Selector::all, cachingStr.str()))
+		if(subject->hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(spellID)), cachingStr.str()))
 			continue;
 
 		auto spellPtr = spellID.toSpell();

+ 3 - 3
lib/battle/CUnitState.cpp

@@ -495,7 +495,7 @@ bool CUnitState::isGhost() const
 
 bool CUnitState::isFrozen() const
 {
-	return hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(SpellID(SpellID::STONE_GAZE))), Selector::all);
+	return hasBonus(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(SpellID(SpellID::STONE_GAZE))));
 }
 
 bool CUnitState::isValidTarget(bool allowDead) const
@@ -948,9 +948,9 @@ CUnitStateDetached::CUnitStateDetached(const IUnitInfo * unit_, const IBonusBear
 {
 }
 
-TConstBonusListPtr CUnitStateDetached::getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr) const
+TConstBonusListPtr CUnitStateDetached::getAllBonuses(const CSelector & selector, const std::string & cachingStr) const
 {
-	return bonus->getAllBonuses(selector, limit, cachingStr);
+	return bonus->getAllBonuses(selector, cachingStr);
 }
 
 int32_t CUnitStateDetached::getTreeVersion() const

+ 1 - 1
lib/battle/CUnitState.h

@@ -278,7 +278,7 @@ public:
 
 	CUnitStateDetached & operator= (const CUnitState & other);
 
-	TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr = "") const override;
+	TConstBonusListPtr getAllBonuses(const CSelector & selector, const std::string & cachingStr = "") const override;
 
 	int32_t getTreeVersion() const override;
 

+ 1 - 1
lib/battle/DamageCalculator.cpp

@@ -523,7 +523,7 @@ int DamageCalculator::battleBonusValue(const IBonusBearer * bearer, const CSelec
 						: Selector::effectRange()(BonusLimitEffect::ONLY_MELEE_FIGHT);
 
 	//any regular bonuses or just ones for melee/ranged
-	return bearer->getBonuses(selector, noLimit.Or(limitMatches))->totalValue();
+	return bearer->getBonuses(selector)->valOfBonuses(noLimit.Or(limitMatches));
 };
 
 DamageEstimation DamageCalculator::calculateDmgRange() const

+ 3 - 4
lib/bonuses/BonusList.cpp

@@ -172,11 +172,11 @@ std::shared_ptr<const Bonus> BonusList::getFirst(const CSelector &selector) cons
 	return nullptr;
 }
 
-void BonusList::getBonuses(BonusList & out, const CSelector &selector, const CSelector &limit) const
+void BonusList::getBonuses(BonusList & out, const CSelector &selector) const
 {
 	for(const auto & b : bonuses)
 	{
-		if(selector(b.get()) && (!limit || ((bool)limit && limit(b.get()))))
+		if(selector(b.get()))
 			out.push_back(b);
 	}
 }
@@ -190,8 +190,7 @@ void BonusList::getAllBonuses(BonusList &out) const
 int BonusList::valOfBonuses(const CSelector &select, int baseValue) const
 {
 	BonusList ret;
-	CSelector limit = nullptr;
-	getBonuses(ret, select, limit);
+	getBonuses(ret, select);
 	return ret.totalValue(baseValue);
 }
 

+ 1 - 1
lib/bonuses/BonusList.h

@@ -54,7 +54,7 @@ public:
 	// BonusList functions
 	void stackBonuses();
 	int totalValue(int baseValue = 0) const;
-	void getBonuses(BonusList &out, const CSelector &selector, const CSelector &limit = nullptr) const;
+	void getBonuses(BonusList &out, const CSelector &selector) const;
 	void getAllBonuses(BonusList &out) const;
 
 	//special find functions

+ 9 - 9
lib/bonuses/CBonusSystemNode.cpp

@@ -80,7 +80,7 @@ void CBonusSystemNode::getAllBonusesRec(BonusList &out) const
 	}
 }
 
-TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr) const
+TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, const std::string &cachingStr) const
 {
 	if (cachingEnabled)
 	{
@@ -103,7 +103,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
 		{
 			// Cached bonuses are up-to-date - use shared/read access and compute results
 			std::shared_lock lock(sync);
-			cachedBonuses.getBonuses(*ret, selector, limit);
+			cachedBonuses.getBonuses(*ret, selector);
 		}
 		else
 		{
@@ -113,7 +113,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
 			if (cachedLast == nodeChanged)
 			{
 				// While our thread was waiting, another one have updated bonus tree. Use cached bonuses.
-				cachedBonuses.getBonuses(*ret, selector, limit);
+				cachedBonuses.getBonuses(*ret, selector);
 			}
 			else
 			{
@@ -126,7 +126,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
 				limitBonuses(allBonuses, cachedBonuses);
 				cachedBonuses.stackBonuses();
 				cachedLast = nodeChanged;
-				cachedBonuses.getBonuses(*ret, selector, limit);
+				cachedBonuses.getBonuses(*ret, selector);
 			}
 		}
 
@@ -147,11 +147,11 @@ TConstBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, co
 	}
 	else
 	{
-		return getAllBonusesWithoutCaching(selector, limit);
+		return getAllBonusesWithoutCaching(selector);
 	}
 }
 
-TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit) const
+TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector &selector) const
 {
 	auto ret = std::make_shared<BonusList>();
 
@@ -160,7 +160,7 @@ TConstBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector
 	BonusList afterLimiting;
 	getAllBonusesRec(beforeLimiting);
 	limitBonuses(beforeLimiting, afterLimiting);
-	afterLimiting.getBonuses(*ret, selector, limit);
+	afterLimiting.getBonuses(*ret, selector);
 	ret->stackBonuses();
 	return ret;
 }
@@ -300,7 +300,7 @@ void CBonusSystemNode::removeBonusesRecursive(const CSelector & s)
 void CBonusSystemNode::reduceBonusDurations(const CSelector &s)
 {
 	BonusList bl;
-	exportedBonuses.getBonuses(bl, s, Selector::all);
+	exportedBonuses.getBonuses(bl, s);
 	for(const auto & b : bl)
 	{
 		b->turnsRemain--;
@@ -351,7 +351,7 @@ void CBonusSystemNode::removeBonus(const std::shared_ptr<Bonus>& b)
 void CBonusSystemNode::removeBonuses(const CSelector & selector)
 {
 	BonusList toRemove;
-	exportedBonuses.getBonuses(toRemove, selector, Selector::all);
+	exportedBonuses.getBonuses(toRemove, selector);
 	for(const auto & bonus : toRemove)
 		removeBonus(bonus);
 }

+ 2 - 2
lib/bonuses/CBonusSystemNode.h

@@ -70,7 +70,7 @@ private:
 	mutable std::shared_mutex sync;
 
 	void getAllBonusesRec(BonusList &out) const;
-	TConstBonusListPtr getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit) const;
+	TConstBonusListPtr getAllBonusesWithoutCaching(const CSelector &selector) const;
 	std::shared_ptr<Bonus> getUpdatedBonus(const std::shared_ptr<Bonus> & b, const TUpdaterPtr & updater) const;
 	void limitBonuses(const BonusList &allBonuses, BonusList &out) const; //out will bo populed with bonuses that are not limited here
 
@@ -101,7 +101,7 @@ public:
 	explicit CBonusSystemNode(ENodeTypes NodeType);
 	virtual ~CBonusSystemNode();
 
-	TConstBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = "") const override;
+	TConstBonusListPtr getAllBonuses(const CSelector &selector, const std::string &cachingStr = "") const override;
 	void getParents(TCNodes &out) const;  //retrieves list of parent nodes (nodes to inherit bonuses from),
 
 	/// Returns first bonus matching selector

+ 3 - 13
lib/bonuses/IBonusBearer.cpp

@@ -17,7 +17,7 @@ VCMI_LIB_NAMESPACE_BEGIN
 
 int IBonusBearer::valOfBonuses(const CSelector &selector, const std::string &cachingStr, int baseValue) const
 {
-	TConstBonusListPtr hlp = getAllBonuses(selector, nullptr, cachingStr);
+	TConstBonusListPtr hlp = getAllBonuses(selector, cachingStr);
 	return hlp->totalValue(baseValue);
 }
 
@@ -27,19 +27,9 @@ bool IBonusBearer::hasBonus(const CSelector &selector, const std::string &cachin
 	return !getBonuses(selector, cachingStr)->empty();
 }
 
-bool IBonusBearer::hasBonus(const CSelector &selector, const CSelector &limit, const std::string &cachingStr) const
-{
-	return !getBonuses(selector, limit, cachingStr)->empty();
-}
-
 TConstBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const std::string &cachingStr) const
 {
-	return getAllBonuses(selector, nullptr, cachingStr);
-}
-
-TConstBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr) const
-{
-	return getAllBonuses(selector, limit, cachingStr);
+	return getAllBonuses(selector, cachingStr);
 }
 
 TConstBonusListPtr IBonusBearer::getBonusesFrom(BonusSource source) const
@@ -120,7 +110,7 @@ bool IBonusBearer::hasBonusFrom(BonusSource source) const
 
 std::shared_ptr<const Bonus> IBonusBearer::getBonus(const CSelector &selector) const
 {
-	auto bonuses = getAllBonuses(selector, Selector::all);
+	auto bonuses = getAllBonuses(selector);
 	return bonuses->getFirst(Selector::all);
 }
 

+ 1 - 3
lib/bonuses/IBonusBearer.h

@@ -20,11 +20,9 @@ public:
 	// * selector is predicate that tests if Bonus matches our criteria
 	IBonusBearer() = default;
 	virtual ~IBonusBearer() = default;
-	virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const = 0;
+	virtual TConstBonusListPtr getAllBonuses(const CSelector &selector, const std::string &cachingStr = {}) const = 0;
 	int valOfBonuses(const CSelector &selector, const std::string &cachingStr = {}, int baseValue = 0) const;
 	bool hasBonus(const CSelector &selector, const std::string &cachingStr = {}) const;
-	bool hasBonus(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const;
-	TConstBonusListPtr getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr = {}) const;
 	TConstBonusListPtr getBonuses(const CSelector &selector, const std::string &cachingStr = {}) const;
 
 	std::shared_ptr<const Bonus> getBonus(const CSelector &selector) const; //returns any bonus visible on node that matches (or nullptr if none matches)

+ 1 - 1
lib/spells/AdventureSpellMechanics.cpp

@@ -317,7 +317,7 @@ bool DimensionDoorMechanics::canBeCastImpl(spells::Problem & problem, const IGam
 	std::stringstream cachingStr;
 	cachingStr << "source_" << vstd::to_underlying(BonusSource::SPELL_EFFECT) << "id_" << owner->id.num;
 
-	int castsAlreadyPerformedThisTurn = caster->getHeroCaster()->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(owner->id)), Selector::all, cachingStr.str())->size();
+	int castsAlreadyPerformedThisTurn = caster->getHeroCaster()->getBonuses(Selector::source(BonusSource::SPELL_EFFECT, BonusSourceID(owner->id)), cachingStr.str())->size();
 	int castsLimit = owner->getLevelPower(schoolLevel);
 
 	bool isTournamentRulesLimitEnabled = cb->getSettings().getBoolean(EGameSettings::DIMENSION_DOOR_TOURNAMENT_RULES_LIMIT);

+ 8 - 7
scripting/lua/api/BonusSystem.cpp

@@ -246,21 +246,22 @@ int BonusBearerProxy::getBonuses(lua_State * L)
 
 		if(hasRangeSelector)
 		{
-			auto rangeSelector = [](const Bonus * b)
-			{
-				return false;//TODO: BonusBearerProxy::getBonuses rangeSelector
-			};
+			//TODO: BonusBearerProxy::getBonuses rangeSelector
+			//auto rangeSelector = [](const Bonus * b)
+			//{
+			//	return false;
+			//};
 
-			ret = object->getBonuses(selector, rangeSelector);
+			ret = object->getBonuses(selector);
 		}
 		else
 		{
-			ret = object->getBonuses(selector, Selector::all);
+			ret = object->getBonuses(selector);
 		}
 	}
 	else
 	{
-		ret = object->getBonuses(Selector::all, Selector::all);
+		ret = object->getBonuses(Selector::all);
 	}
 
 	S.clear();

+ 2 - 2
test/battle/CBattleInfoCallbackTest.cpp

@@ -83,13 +83,13 @@ public:
 
 	void redirectBonusesToFake()
 	{
-		ON_CALL(*this, getAllBonuses(_, _, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
+		ON_CALL(*this, getAllBonuses(_, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
 		ON_CALL(*this, getTreeVersion()).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getTreeVersion));
 	}
 
 	void expectAnyBonusSystemCall()
 	{
-		EXPECT_CALL(*this, getAllBonuses(_, _, _)).Times(AtLeast(0));
+		EXPECT_CALL(*this, getAllBonuses(_, _)).Times(AtLeast(0));
 		EXPECT_CALL(*this, getTreeVersion()).Times(AtLeast(0));
 	}
 

+ 2 - 2
test/battle/CHealthTest.cpp

@@ -29,7 +29,7 @@ public:
 
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(mock, getAllBonuses(_, _, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
+		EXPECT_CALL(mock, getAllBonuses(_, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
 		EXPECT_CALL(mock, getTreeVersion()).WillRepeatedly(Return(1));
 
 		bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, UNIT_HEALTH, BonusSourceID()));
@@ -235,7 +235,7 @@ TEST_F(HealthTest, singleUnitStack)
 
 	//one Titan
 
-	EXPECT_CALL(mock, getAllBonuses(_, _, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
+	EXPECT_CALL(mock, getAllBonuses(_, _)).WillRepeatedly(Invoke(&bonusMock, &BonusBearerMock::getAllBonuses));
 	EXPECT_CALL(mock, getTreeVersion()).WillRepeatedly(Return(1));
 
 	bonusMock.addNewBonus(std::make_shared<Bonus>(BonusDuration::PERMANENT, BonusType::STACK_HEALTH, BonusSource::CREATURE_ABILITY, 300, BonusSourceID()));

+ 2 - 2
test/mock/BattleFake.cpp

@@ -34,13 +34,13 @@ void UnitFake::makeDead()
 
 void UnitFake::redirectBonusesToFake()
 {
-	ON_CALL(*this, getAllBonuses(_, _, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
+	ON_CALL(*this, getAllBonuses(_, _)).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getAllBonuses));
 	ON_CALL(*this, getTreeVersion()).WillByDefault(Invoke(&bonusFake, &BonusBearerMock::getTreeVersion));
 }
 
 void UnitFake::expectAnyBonusSystemCall()
 {
-	EXPECT_CALL(*this, getAllBonuses(_, _, _)).Times(AtLeast(0));
+	EXPECT_CALL(*this, getAllBonuses(_, _)).Times(AtLeast(0));
 	EXPECT_CALL(*this, getTreeVersion()).Times(AtLeast(0));
 }
 

+ 2 - 2
test/mock/mock_BonusBearer.cpp

@@ -25,7 +25,7 @@ void BonusBearerMock::addNewBonus(const std::shared_ptr<Bonus> & b)
 	treeVersion++;
 }
 
-TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr) const
+TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, const std::string & cachingStr) const
 {
 	if(cachedLast != treeVersion)
 	{
@@ -34,7 +34,7 @@ TConstBonusListPtr BonusBearerMock::getAllBonuses(const CSelector & selector, co
 	}
 
 	auto ret = std::make_shared<BonusList>();
-	bonuses.getBonuses(*ret, selector, limit);
+	bonuses.getBonuses(*ret, selector);
 	return ret;
 }
 

+ 1 - 1
test/mock/mock_BonusBearer.h

@@ -23,7 +23,7 @@ public:
 
 	void addNewBonus(const std::shared_ptr<Bonus> & b);
 
-	TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit, const std::string & cachingStr = "") const override;
+	TConstBonusListPtr getAllBonuses(const CSelector & selector, const std::string & cachingStr = "") const override;
 
 	int32_t getTreeVersion() const override;
 private:

+ 1 - 1
test/mock/mock_battle_Unit.h

@@ -15,7 +15,7 @@
 class UnitMock : public battle::Unit
 {
 public:
-	MOCK_CONST_METHOD3(getAllBonuses, TConstBonusListPtr(const CSelector &, const CSelector &, const std::string &));
+	MOCK_CONST_METHOD2(getAllBonuses, TConstBonusListPtr(const CSelector &, const std::string &));
 	MOCK_CONST_METHOD0(getTreeVersion, int32_t());
 
 	MOCK_CONST_METHOD0(getCasterUnitId, int32_t());

+ 3 - 3
test/spells/AbilityCasterTest.cpp

@@ -33,7 +33,7 @@ public:
 protected:
 	void SetUp() override
 	{
-		ON_CALL(actualCaster, getAllBonuses(_, _, _)).WillByDefault(Invoke(&casterBonuses, &BonusBearerMock::getAllBonuses));
+		ON_CALL(actualCaster, getAllBonuses(_, _)).WillByDefault(Invoke(&casterBonuses, &BonusBearerMock::getAllBonuses));
 		ON_CALL(actualCaster, getTreeVersion()).WillByDefault(Invoke(&casterBonuses, &BonusBearerMock::getTreeVersion));
 	}
 
@@ -57,7 +57,7 @@ TEST_F(AbilityCasterTest, MagicAbilityAffectedByGenericBonus)
 
 	casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, BonusSourceID(), BonusSubtypeID(SpellSchool::ANY)));
 
-	EXPECT_CALL(actualCaster, getAllBonuses(_, _, _)).Times(AtLeast(1));
+	EXPECT_CALL(actualCaster, getAllBonuses(_, _)).Times(AtLeast(1));
 	EXPECT_CALL(actualCaster, getTreeVersion()).Times(AtLeast(0));
 
 	setupSubject(1);
@@ -71,7 +71,7 @@ TEST_F(AbilityCasterTest, MagicAbilityIgnoresSchoolBonus)
 
 	casterBonuses.addNewBonus(std::make_shared<Bonus>(BonusDuration::ONE_BATTLE, BonusType::MAGIC_SCHOOL_SKILL, BonusSource::OTHER, 2, BonusSourceID(), BonusSubtypeID(SpellSchool::AIR)));
 
-	EXPECT_CALL(actualCaster, getAllBonuses(_, _, _)).Times(AtLeast(1));
+	EXPECT_CALL(actualCaster, getAllBonuses(_, _)).Times(AtLeast(1));
 	EXPECT_CALL(actualCaster, getTreeVersion()).Times(AtLeast(0));
 
 	setupSubject(1);

+ 1 - 1
test/spells/targetConditions/AbsoluteLevelConditionTest.cpp

@@ -24,7 +24,7 @@ public:
 	void setDefaultExpectations()
 	{
 		EXPECT_CALL(mechanicsMock, isMagicalEffect()).WillRepeatedly(Return(true));
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 	}
 

+ 1 - 1
test/spells/targetConditions/AbsoluteSpellConditionTest.cpp

@@ -24,7 +24,7 @@ public:
 
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 		EXPECT_CALL(mechanicsMock, getSpellIndex()).WillRepeatedly(Return(castSpell));
 	}

+ 1 - 1
test/spells/targetConditions/BonusConditionTest.cpp

@@ -21,7 +21,7 @@ class BonusConditionTest : public TargetConditionItemTest
 public:
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 	}
 

+ 1 - 1
test/spells/targetConditions/CreatureConditionTest.cpp

@@ -21,7 +21,7 @@ class CreatureConditionTest : public TargetConditionItemTest
 public:
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(0);
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(0);
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(0);
 	}
 

+ 1 - 1
test/spells/targetConditions/ElementalConditionTest.cpp

@@ -23,7 +23,7 @@ public:
 
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 
 		EXPECT_CALL(mechanicsMock, getSpell()).Times(AtLeast(1)).WillRepeatedly(Return(&spellMock));

+ 1 - 1
test/spells/targetConditions/HealthValueConditionTest.cpp

@@ -23,7 +23,7 @@ public:
 	const int64_t EFFECT_VALUE = 101;
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(0);
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(0);
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(0);
 		EXPECT_CALL(unitMock, getAvailableHealth()).WillOnce(Return(UNIT_HP));
 		EXPECT_CALL(mechanicsMock, getEffectValue()).WillOnce(Return(EFFECT_VALUE));

+ 1 - 1
test/spells/targetConditions/ImmunityNegationConditionTest.cpp

@@ -30,7 +30,7 @@ public:
 	{
 		ownerMatches = ::testing::get<0>(GetParam());
 		isMagicalEffect = ::testing::get<1>(GetParam());
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(0));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(0));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 		EXPECT_CALL(mechanicsMock, isMagicalEffect()).Times(AtLeast(0)).WillRepeatedly(Return(isMagicalEffect));
 		EXPECT_CALL(mechanicsMock, ownerMatches(Eq(&unitMock), Field(&boost::logic::tribool::value, boost::logic::tribool::false_value))).WillRepeatedly(Return(ownerMatches));

+ 1 - 1
test/spells/targetConditions/NormalLevelConditionTest.cpp

@@ -27,7 +27,7 @@ public:
 		isMagicalEffect = GetParam();
 		EXPECT_CALL(mechanicsMock, isMagicalEffect()).WillRepeatedly(Return(isMagicalEffect));
 		if(isMagicalEffect)
-			EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
+			EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 	}
 

+ 1 - 1
test/spells/targetConditions/NormalSpellConditionTest.cpp

@@ -24,7 +24,7 @@ public:
 
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 		EXPECT_CALL(mechanicsMock, getSpellIndex()).WillRepeatedly(Return(castSpell));
 	}

+ 1 - 1
test/spells/targetConditions/ReceptiveFeatureConditionTest.cpp

@@ -27,7 +27,7 @@ public:
 		isPositive = ::testing::get<0>(GetParam());
 		hasBonus = ::testing::get<1>(GetParam());
 
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(0));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(0));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 		EXPECT_CALL(mechanicsMock, isPositiveSpell()).WillRepeatedly(Return(isPositive));
 		if(hasBonus)

+ 1 - 1
test/spells/targetConditions/SpellEffectConditionTest.cpp

@@ -21,7 +21,7 @@ class SpellEffectConditionTest : public TargetConditionItemTest
 public:
 	void setDefaultExpectations()
 	{
-		EXPECT_CALL(unitMock, getAllBonuses(_, _, _)).Times(AtLeast(1));
+		EXPECT_CALL(unitMock, getAllBonuses(_, _)).Times(AtLeast(1));
 		EXPECT_CALL(unitMock, getTreeVersion()).Times(AtLeast(0));
 	}
 

+ 1 - 1
test/spells/targetConditions/TargetConditionItemFixture.h

@@ -37,7 +37,7 @@ protected:
 	void SetUp() override
 	{
 		using namespace ::testing;
-		ON_CALL(unitMock, getAllBonuses(_, _, _)).WillByDefault(Invoke(&unitBonuses, &BonusBearerMock::getAllBonuses));
+		ON_CALL(unitMock, getAllBonuses(_, _)).WillByDefault(Invoke(&unitBonuses, &BonusBearerMock::getAllBonuses));
 		ON_CALL(unitMock, getTreeVersion()).WillByDefault(Invoke(&unitBonuses, &BonusBearerMock::getTreeVersion));
 	}
 };