Răsfoiți Sursa

Style tweaks

AlexVinS 9 ani în urmă
părinte
comite
c0cf5d6956

+ 1 - 1
lib/spells/BattleSpellMechanics.cpp

@@ -386,7 +386,7 @@ ESpellCastProblem::ESpellCastProblem ObstacleMechanics::canBeCast(const SpellTar
 
 		bool hexesOutsideBattlefield = false;
 
-		auto tilesThatMustBeClear = owner->rangeInHexes(ctx.destination, ctx.caster->getSpellSchoolLevel(owner), side, &hexesOutsideBattlefield);
+		auto tilesThatMustBeClear = owner->rangeInHexes(ctx.destination, ctx.schoolLvl, side, &hexesOutsideBattlefield);
 
 		for(BattleHex hex : tilesThatMustBeClear)
 		{

+ 7 - 9
lib/spells/CDefaultSpellMechanics.cpp

@@ -675,37 +675,35 @@ std::set<const CStack *> DefaultSpellMechanics::getAffectedStacks(SpellTargeting
 	const ui8 attackerSide = ctx.cb->playerToSide(ctx.caster->getOwner()) == 1;
 	const auto attackedHexes = rangeInHexes(ctx.destination, ctx.schoolLvl, attackerSide);
 
-	const CSpell::TargetInfo ti(owner, ctx.schoolLvl, ctx.mode);
-
 	//TODO: more generic solution for mass spells
 	if(owner->getLevelInfo(ctx.schoolLvl).range.size() > 1) //custom many-hex range
 	{
 		for(BattleHex hex : attackedHexes)
 		{
-			if(const CStack * st = ctx.cb->battleGetStackByPos(hex, ti.onlyAlive))
+			if(const CStack * st = ctx.cb->battleGetStackByPos(hex, ctx.ti.onlyAlive))
 			{
 				attackedCres.insert(st);
 			}
 		}
 	}
-	else if(ti.type == CSpell::CREATURE)
+	else if(ctx.ti.type == CSpell::CREATURE)
 	{
 		auto predicate = [=](const CStack * s){
 			const bool positiveToAlly = owner->isPositive() && s->owner == ctx.caster->getOwner();
 			const bool negativeToEnemy = owner->isNegative() && s->owner != ctx.caster->getOwner();
-			const bool validTarget = s->isValidTarget(!ti.onlyAlive); //todo: this should be handled by spell class
+			const bool validTarget = s->isValidTarget(!ctx.ti.onlyAlive); //todo: this should be handled by spell class
 
 			//for single target spells select stacks covering destination tile
-			const bool rangeCovers = ti.massive || s->coversPos(ctx.destination);
+			const bool rangeCovers = ctx.ti.massive || s->coversPos(ctx.destination);
 			//handle smart targeting
-			const bool positivenessFlag = !ti.smart || owner->isNeutral() || positiveToAlly || negativeToEnemy;
+			const bool positivenessFlag = !ctx.ti.smart || owner->isNeutral() || positiveToAlly || negativeToEnemy;
 
 			return rangeCovers && positivenessFlag && validTarget;
 		};
 
 		TStacks stacks = ctx.cb->battleGetStacksIf(predicate);
 
-		if(ti.massive)
+		if(ctx.ti.massive)
 		{
 			//for massive spells add all targets
 			for (auto stack : stacks)
@@ -733,7 +731,7 @@ std::set<const CStack *> DefaultSpellMechanics::getAffectedStacks(SpellTargeting
 	{
 		for(BattleHex hex : attackedHexes)
 		{
-			if(const CStack * st = ctx.cb->battleGetStackByPos(hex, ti.onlyAlive))
+			if(const CStack * st = ctx.cb->battleGetStackByPos(hex, ctx.ti.onlyAlive))
 				attackedCres.insert(st);
 		}
 	}

+ 2 - 2
lib/spells/ISpellMechanics.h

@@ -94,8 +94,8 @@ public:
 		const ISpellCaster * caster;
 		int schoolLvl;
 
-		SpellTargetingContext(const CSpell * s, const CBattleInfoCallback * c, ECastingMode::ECastingMode m, const ISpellCaster * caster_, int lvl, BattleHex dest)
-			: cb(c), ti(s,lvl, m), mode(m), destination(dest), caster(caster_), schoolLvl(lvl)
+		SpellTargetingContext(const CSpell * s, const CBattleInfoCallback * c, ECastingMode::ECastingMode mode_, const ISpellCaster * caster_, int schoolLvl_, BattleHex destination_)
+			: cb(c), ti(s,schoolLvl_, mode_), mode(mode_), destination(destination_), caster(caster_), schoolLvl(schoolLvl_)
 		{};
 
 	};