[10584] Prevent lost aura connection with item at Aura::ReapplyAffectedPassiveAuras

Thanks to Lynx3d for research problem and testing.
This commit is contained in:
VladimirMangos 2010-10-07 03:05:11 +04:00
parent 15e6c17158
commit 3d5298fbd7
2 changed files with 15 additions and 6 deletions

View file

@ -953,7 +953,10 @@ bool Aura::CanProcFrom(SpellEntry const *spell, uint32 EventProcEx, uint32 procE
void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode ) void Aura::ReapplyAffectedPassiveAuras( Unit* target, bool owner_mode )
{ {
std::set<uint32> 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<uint32, ObjectGuid> affectedSelf;
std::set<uint32> affectedAuraCaster; std::set<uint32> affectedAuraCaster;
for(Unit::SpellAuraHolderMap::const_iterator itr = target->GetSpellAuraHolderMap().begin(); itr != target->GetSpellAuraHolderMap().end(); ++itr) 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 // only applied by self or aura caster
if (itr->second->GetCasterGUID() == target->GetGUID()) if (itr->second->GetCasterGUID() == target->GetGUID())
affectedSelf.insert(itr->second->GetId()); affectedSelf[itr->second->GetId()] = itr->second->GetCastItemGUID();
else if (itr->second->GetCasterGUID() == GetCasterGUID()) else if (itr->second->GetCasterGUID() == GetCasterGUID())
affectedAuraCaster.insert(itr->second->GetId()); affectedAuraCaster.insert(itr->second->GetId());
} }
} }
for(std::set<uint32>::const_iterator set_itr = affectedSelf.begin(); set_itr != affectedSelf.end(); ++set_itr) if (!affectedSelf.empty())
{ {
target->RemoveAurasDueToSpell(*set_itr); Player* pTarget = target->GetTypeId() == TYPEID_PLAYER ? (Player*)target : NULL;
target->CastSpell(GetTarget(), *set_itr, true);
for(std::map<uint32, ObjectGuid>::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()) if (!affectedAuraCaster.empty())

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10583" #define REVISION_NR "10584"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__