DjWarmonger 12 years ago
parent
commit
9277c695a5
3 changed files with 8 additions and 5 deletions
  1. 1 1
      lib/BattleState.cpp
  2. 1 1
      lib/BattleState.h
  3. 6 3
      server/CGameHandler.cpp

+ 1 - 1
lib/BattleState.cpp

@@ -716,7 +716,7 @@ const CGHeroInstance * BattleInfo::getHero( PlayerColor player ) const
 	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;
 	for(auto & affectedCreature : affectedCreatures)

+ 1 - 1
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<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 CGHeroInstance * battleGetOwner(const CStack * stack) const; //returns hero that owns given stack; nullptr if none

+ 6 - 3
server/CGameHandler.cpp

@@ -3967,10 +3967,12 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 	}
 
 	//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)
 	{
-		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);