Explorar el Código

get rid of CPlayerBattleCallback::battleCanCastThisSpell

AlexVinS hace 8 años
padre
commit
2cfb2e6ae0
Se han modificado 4 ficheros con 4 adiciones y 17 borrados
  1. 2 2
      AI/BattleAI/BattleAI.cpp
  2. 2 2
      client/windows/CSpellWindow.cpp
  3. 0 12
      lib/CBattleCallback.cpp
  4. 0 1
      lib/CBattleCallback.h

+ 2 - 2
AI/BattleAI/BattleAI.cpp

@@ -192,9 +192,9 @@ void CBattleAI::attemptCastingSpell()
 	LOGL("Casting spells sounds like fun. Let's see...");
 	LOGL("Casting spells sounds like fun. Let's see...");
 	//Get all spells we can cast
 	//Get all spells we can cast
 	std::vector<const CSpell*> possibleSpells;
 	std::vector<const CSpell*> possibleSpells;
-	vstd::copy_if(VLC->spellh->objects, std::back_inserter(possibleSpells), [this] (const CSpell *s) -> bool
+	vstd::copy_if(VLC->spellh->objects, std::back_inserter(possibleSpells), [this, hero] (const CSpell *s) -> bool
 	{
 	{
-		auto problem = getCbc()->battleCanCastThisSpell(s);
+		auto problem = getCbc()->battleCanCastThisSpell(hero, s, ECastingMode::HERO_CASTING);
 		return problem == ESpellCastProblem::OK;
 		return problem == ESpellCastProblem::OK;
 	});
 	});
 	LOGFL("I can cast %d spells.", possibleSpells.size());
 	LOGFL("I can cast %d spells.", possibleSpells.size());

+ 2 - 2
client/windows/CSpellWindow.cpp

@@ -547,9 +547,9 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 		}
 		}
 
 
 		//we will cast a spell
 		//we will cast a spell
-		if(mySpell->combatSpell && owner->myInt->battleInt) //if battle window is open
+		if(mySpell->isCombatSpell() && owner->myInt->battleInt) //if battle window is open
 		{
 		{
-			ESpellCastProblem::ESpellCastProblem problem = owner->myInt->cb->battleCanCastThisSpell(mySpell);
+			ESpellCastProblem::ESpellCastProblem problem = owner->myInt->cb->battleCanCastThisSpell(owner->myHero, mySpell, ECastingMode::HERO_CASTING);
 			switch (problem)
 			switch (problem)
 			{
 			{
 			case ESpellCastProblem::OK:
 			case ESpellCastProblem::OK:

+ 0 - 12
lib/CBattleCallback.cpp

@@ -2111,18 +2111,6 @@ ReachabilityInfo::Parameters::Parameters(const CStack *Stack)
 	knownAccessible = stack->getHexes();
 	knownAccessible = stack->getHexes();
 }
 }
 
 
-ESpellCastProblem::ESpellCastProblem CPlayerBattleCallback::battleCanCastThisSpell(const CSpell * spell) const
-{
-	RETURN_IF_NOT_BATTLE(ESpellCastProblem::INVALID);
-	ASSERT_IF_CALLED_WITH_PLAYER
-
-	const ISpellCaster * hero = battleGetMyHero();
-	if(hero == nullptr)
-		return ESpellCastProblem::INVALID;
-	else
-		return CBattleInfoCallback::battleCanCastThisSpell(hero, spell, ECastingMode::HERO_CASTING);
-}
-
 bool CPlayerBattleCallback::battleCanFlee() const
 bool CPlayerBattleCallback::battleCanFlee() const
 {
 {
 	RETURN_IF_NOT_BATTLE(false);
 	RETURN_IF_NOT_BATTLE(false);

+ 0 - 1
lib/CBattleCallback.h

@@ -336,7 +336,6 @@ class DLL_LINKAGE CPlayerBattleCallback : public CBattleInfoCallback
 public:
 public:
 	bool battleCanFlee() const; //returns true if caller can flee from the battle
 	bool battleCanFlee() const; //returns true if caller can flee from the battle
 	TStacks battleGetStacks(EStackOwnership whose = MINE_AND_ENEMY, bool onlyAlive = true) const; //returns stacks on battlefield
 	TStacks battleGetStacks(EStackOwnership whose = MINE_AND_ENEMY, bool onlyAlive = true) const; //returns stacks on battlefield
-	ESpellCastProblem::ESpellCastProblem battleCanCastThisSpell(const CSpell * spell) const; //determines if given spell can be cast (and returns problem description)
 
 
 	int battleGetSurrenderCost() const; //returns cost of surrendering battle, -1 if surrendering is not possible
 	int battleGetSurrenderCost() const; //returns cost of surrendering battle, -1 if surrendering is not possible