1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00
This commit is contained in:
DjWarmonger
2013-07-20 08:54:43 +00:00
parent 096d6ebf9c
commit 9277c695a5
3 changed files with 8 additions and 5 deletions

View File

@@ -716,7 +716,7 @@ const CGHeroInstance * BattleInfo::getHero( PlayerColor player ) const
return heroes[1]; return heroes[1];
} }
std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set<const CStack*> affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::vector<const CStack*> affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const
{ {
std::vector<ui32> ret; std::vector<ui32> ret;
for(auto & affectedCreature : affectedCreatures) for(auto & affectedCreature : affectedCreatures)

View File

@@ -116,7 +116,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
const CGHeroInstance * getHero(PlayerColor player) const; //returns fighting hero that belongs to given player const CGHeroInstance * getHero(PlayerColor player) const; //returns fighting hero that belongs to given player
std::vector<ui32> calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set<const CStack*> affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const; std::vector<ui32> calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::vector<const CStack*> affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const;
const CStack * battleGetStack(BattleHex pos, bool onlyAlive); //returns stack at given tile const CStack * battleGetStack(BattleHex pos, bool onlyAlive); //returns stack at given tile
const CGHeroInstance * battleGetOwner(const CStack * stack) const; //returns hero that owns given stack; nullptr if none const CGHeroInstance * battleGetOwner(const CStack * stack) const; //returns hero that owns given stack; nullptr if none

View File

@@ -3967,10 +3967,12 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
} }
//calculating affected creatures for all spells //calculating affected creatures for all spells
std::set<const CStack*> attackedCres; //what is that and what is sc.afectedCres? //must be vector, as in Chain Lightning order matters
std::vector<const CStack*> attackedCres; //what is that and what is sc.afectedCres?
if (mode != ECastingMode::ENCHANTER_CASTING) if (mode != ECastingMode::ENCHANTER_CASTING)
{ {
attackedCres = gs->curB->getAffectedCreatures(spell, spellLvl, casterColor, destination); auto creatures = gs->curB->getAffectedCreatures(spell, spellLvl, casterColor, destination);
std::copy(creatures.begin(), creatures.end(), std::back_inserter(attackedCres));
} }
else //enchanter - hit all possible stacks else //enchanter - hit all possible stacks
{ {
@@ -3982,11 +3984,12 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
{ {
if(stack->isValidTarget()) //TODO: allow dead targets somewhere in the future if(stack->isValidTarget()) //TODO: allow dead targets somewhere in the future
{ {
attackedCres.insert(stack); attackedCres.push_back(stack);
} }
} }
} }
} }
for (auto cre : attackedCres) for (auto cre : attackedCres)
{ {
sc.affectedCres.insert (cre->ID); sc.affectedCres.insert (cre->ID);