diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 2cf4da8d7..86afea550 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -716,7 +716,7 @@ const CGHeroInstance * BattleInfo::getHero( PlayerColor player ) const return heroes[1]; } -std::vector BattleInfo::calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const +std::vector BattleInfo::calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::vector affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const { std::vector ret; for(auto & affectedCreature : affectedCreatures) diff --git a/lib/BattleState.h b/lib/BattleState.h index a8d78fc85..c1a6b9059 100644 --- a/lib/BattleState.h +++ b/lib/BattleState.h @@ -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 - std::vector calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const; + std::vector calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::vector affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const; 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 diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 66cd56ae8..ff5fbacb7 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -3967,10 +3967,12 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex } //calculating affected creatures for all spells - std::set attackedCres; //what is that and what is sc.afectedCres? + //must be vector, as in Chain Lightning order matters + std::vector attackedCres; //what is that and what is sc.afectedCres? 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 { @@ -3982,11 +3984,12 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex { if(stack->isValidTarget()) //TODO: allow dead targets somewhere in the future { - attackedCres.insert(stack); + attackedCres.push_back(stack); } } } } + for (auto cre : attackedCres) { sc.affectedCres.insert (cre->ID);