Explorar o código

remove useless function CSpell::getTargetInfo

AlexVinS %!s(int64=10) %!d(string=hai) anos
pai
achega
d9cbe487c7

+ 1 - 1
client/battle/CBattleInterface.cpp

@@ -1379,7 +1379,7 @@ void CBattleInterface::castThisSpell(SpellID spellID)
 	sp = spellID.toSpell();
 	spellSelMode = ANY_LOCATION;
 
-	const CSpell::TargetInfo ti = sp->getTargetInfo(castingHero->getSpellSchoolLevel(sp));
+	const CSpell::TargetInfo ti(sp, castingHero->getSpellSchoolLevel(sp));
 
 	if(ti.massive || ti.type == CSpell::NO_TARGET)
 		spellSelMode = NO_LOCATION;

+ 2 - 2
lib/CBattleCallback.cpp

@@ -1660,7 +1660,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 		if(mode == ECastingMode::HERO_CASTING)
 		{
 			const CGHeroInstance * caster = battleGetFightingHero(side);
-			const CSpell::TargetInfo ti = spell->getTargetInfo(caster->getSpellSchoolLevel(spell));
+			const CSpell::TargetInfo ti(spell, caster->getSpellSchoolLevel(spell));
 			bool targetExists = false;
 
             for(const CStack * stack : battleGetAllStacks()) //dead stacks will be immune anyway
@@ -1715,7 +1715,7 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetPossibleTargets(PlayerColor
 	case CSpell::CREATURE:
 		{
 			const CGHeroInstance * caster = battleGetFightingHero(playerToSide(player)); //TODO
-			const CSpell::TargetInfo ti = spell->getTargetInfo(caster->getSpellSchoolLevel(spell));
+			const CSpell::TargetInfo ti(spell, caster->getSpellSchoolLevel(spell));
 			
 			for(const CStack * stack : battleAliveStacks())
 			{

+ 3 - 2
lib/spells/BattleSpellMechanics.cpp

@@ -338,8 +338,9 @@ ESpellCastProblem::ESpellCastProblem EarthquakeMechanics::canBeCasted(const CBat
 	{
 		return ESpellCastProblem::NO_APPROPRIATE_TARGET;
 	}
-
-	if(owner->getTargetInfo(0).smart) //TODO: use real spell level
+	
+	CSpell::TargetInfo ti(owner, 0);//TODO: use real spell level
+	if(ti.smart)
 	{
 		//if spell targeting is smart, then only attacker can use it
 		if(cb->playerToSide(player) != 0)

+ 0 - 6
lib/spells/CSpellHandler.cpp

@@ -175,12 +175,6 @@ CSpell::ETargetType CSpell::getTargetType() const
 	return targetType;
 }
 
-CSpell::TargetInfo CSpell::getTargetInfo(const int level) const
-{
-	TargetInfo info(this, level);
-	return info;
-}
-
 void CSpell::forEachSchool(const std::function<void(const SpellSchoolInfo &, bool &)>& cb) const
 {
 	bool stop = false;

+ 1 - 3
lib/spells/CSpellHandler.h

@@ -152,7 +152,7 @@ public:
 	enum ETargetType {NO_TARGET, CREATURE, OBSTACLE, LOCATION};
 	enum ESpellPositiveness {NEGATIVE = -1, NEUTRAL = 0, POSITIVE = 1};
 
-	struct TargetInfo
+	struct DLL_LINKAGE TargetInfo
 	{
 		ETargetType type;
 		bool smart;
@@ -195,8 +195,6 @@ public:
 	std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool * outDroppedHexes = nullptr ) const; //convert range to specific hexes; last optional out parameter is set to true, if spell would cover unavailable hexes (that are not included in ret)
 	ETargetType getTargetType() const; //deprecated
 
-	CSpell::TargetInfo getTargetInfo(const int level) const;
-
 	bool isCombatSpell() const;
 	bool isAdventureSpell() const;
 	bool isCreatureAbility() const;