From 40685ff9b5c5d53601aae778aec23e77117616b9 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Thu, 7 Oct 2010 03:05:11 +0400 Subject: [PATCH] [10584] Prevent lost aura connection with item at Aura::ReapplyAffectedPassiveAuras Thanks to Lynx3d for research problem and testing. --- src/game/SpellAuras.cpp | 19 ++++++++++++++----- src/shared/revision_nr.h | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 86ff9661f54..29edbc9000c 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -953,7 +953,10 @@ bool Aura::CanProcFrom(SpellEntry const *spell, uint32 EventProcEx, uint32 procE void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode ) { - std::set affectedSelf; + // we need store cast item guids for self casted spells + // expected that not exist permanent auras from stackable auras from different items + std::map affectedSelf; + std::set affectedAuraCaster; for(Unit::SpellAuraHolderMap::const_iterator itr = target->GetSpellAuraHolderMap().begin(); itr != target->GetSpellAuraHolderMap().end(); ++itr) @@ -968,16 +971,22 @@ void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode ) { // only applied by self or aura caster if (itr->second->GetCasterGUID() == target->GetGUID()) - affectedSelf.insert(itr->second->GetId()); + affectedSelf[itr->second->GetId()] = itr->second->GetCastItemGUID(); else if (itr->second->GetCasterGUID() == GetCasterGUID()) affectedAuraCaster.insert(itr->second->GetId()); } } - for(std::set::const_iterator set_itr = affectedSelf.begin(); set_itr != affectedSelf.end(); ++set_itr) + if (!affectedSelf.empty()) { - target->RemoveAurasDueToSpell(*set_itr); - target->CastSpell(GetTarget(), *set_itr, true); + Player* pTarget = target->GetTypeId() == TYPEID_PLAYER ? (Player*)target : NULL; + + for(std::map::const_iterator map_itr = affectedSelf.begin(); map_itr != affectedSelf.end(); ++map_itr) + { + Item* item = pTarget && !map_itr->second.IsEmpty() ? pTarget->GetItemByGuid(map_itr->second) : NULL; + target->RemoveAurasDueToSpell(map_itr->first); + target->CastSpell(target, map_itr->first, true, item); + } } if (!affectedAuraCaster.empty()) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index d625dce613e..464704eceb2 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10583" + #define REVISION_NR "10584" #endif // __REVISION_NR_H__