*Try to fix a crash caused by single target auras. Thanks to QAston.
--HG-- branch : trunk
This commit is contained in:
+6
-8
@@ -1169,6 +1169,11 @@ void Pet::_LoadAuras(uint32 timediff)
|
||||
|
||||
Aura* aura = new Aura(spellproto, effmask, NULL, this, NULL, NULL);
|
||||
aura->SetLoadedState(caster_guid,maxduration,remaintime,remaincharges, stackcount, &damage[0]);
|
||||
if(!aura->CanBeSaved())
|
||||
{
|
||||
delete aura;
|
||||
continue;
|
||||
}
|
||||
AddAura(aura);
|
||||
sLog.outDetail("Added aura spellid %u, effectmask %u", spellproto->Id, effmask);
|
||||
}
|
||||
@@ -1185,14 +1190,7 @@ void Pet::_SaveAuras()
|
||||
AuraMap const& auras = GetAuras();
|
||||
for(AuraMap::const_iterator itr = auras.begin(); itr !=auras.end() ; ++itr)
|
||||
{
|
||||
// skip all auras from spell that apply at cast SPELL_AURA_MOD_SHAPESHIFT or pet area auras.
|
||||
// do not save single target auras (unless they were cast by the player)
|
||||
if (itr->second->IsPassive() || itr->second->IsAuraType(SPELL_AURA_MOD_STEALTH))
|
||||
continue;
|
||||
bool isCaster = itr->second->GetCasterGUID() == GetGUID();
|
||||
if (!isCaster)
|
||||
if (itr->second->IsSingleTarget()
|
||||
|| itr->second->IsAreaAura())
|
||||
if(!itr->second->CanBeSaved())
|
||||
continue;
|
||||
|
||||
int32 amounts[MAX_SPELL_EFFECTS];
|
||||
|
||||
+6
-9
@@ -15195,6 +15195,11 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
||||
|
||||
Aura* aura = new Aura(spellproto, effmask, NULL, this, NULL, NULL);
|
||||
aura->SetLoadedState(caster_guid,maxduration,remaintime,remaincharges, stackcount, &damage[0]);
|
||||
if(!aura->CanBeSaved())
|
||||
{
|
||||
delete aura;
|
||||
continue;
|
||||
}
|
||||
AddAura(aura);
|
||||
sLog.outDetail("Added aura spellid %u, effectmask %u", spellproto->Id, effmask);
|
||||
}
|
||||
@@ -16275,15 +16280,7 @@ void Player::_SaveAuras()
|
||||
AuraMap const& auras = GetAuras();
|
||||
for(AuraMap::const_iterator itr = auras.begin(); itr !=auras.end() ; ++itr)
|
||||
{
|
||||
// skip:
|
||||
// area auras or single cast auras casted by other unit
|
||||
// passive auras and stances
|
||||
if (itr->second->IsPassive())
|
||||
continue;
|
||||
|
||||
if (itr->second->GetCasterGUID() != GetGUID())
|
||||
if (IsSingleTargetSpell(itr->second->GetSpellProto())
|
||||
|| itr->second->IsAreaAura())
|
||||
if(!itr->second->CanBeSaved())
|
||||
continue;
|
||||
|
||||
int32 amounts[MAX_SPELL_EFFECTS];
|
||||
|
||||
+13
-1
@@ -1521,6 +1521,18 @@ bool Aura::DropAuraCharge()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Aura::CanBeSaved() const
|
||||
{
|
||||
if (IsPassive())
|
||||
return false;
|
||||
|
||||
if (GetCasterGUID() != m_target->GetGUID())
|
||||
if (IsSingleTargetSpell(GetSpellProto()) || IsAreaAura())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Aura::IsPersistent() const
|
||||
{
|
||||
for(uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
@@ -1799,7 +1811,7 @@ void Aura::UnregisterSingleCastAura()
|
||||
}
|
||||
else
|
||||
{
|
||||
sLog.outError("Couldn't find the caster of the single target aura, may crash later!");
|
||||
sLog.outCrash("Couldn't find the caster (guid: "UI64FMTD") of the single target aura %u which is on unit entry %u class %u, may crash later!", GetCasterGUID(), GetId(), m_target->GetEntry(), m_target->getClass());
|
||||
assert(false);
|
||||
}
|
||||
m_isSingleTargetAura = false;
|
||||
|
||||
@@ -101,6 +101,7 @@ class TRINITY_DLL_SPEC Aura
|
||||
bool IsPassive() const { return m_isPassive; }
|
||||
bool IsDeathPersistent() const { return m_isDeathPersist; }
|
||||
bool IsRemovedOnShapeLost() const { return m_isRemovedOnShapeLost; }
|
||||
bool CanBeSaved() const;
|
||||
bool IsUpdated() const { return m_updated; }
|
||||
bool IsRemoved() const { return m_isRemoved; }
|
||||
void SetUpdated(bool val) { m_updated = val; }
|
||||
|
||||
+2
-3
@@ -3924,8 +3924,7 @@ bool Unit::AddAura(Aura *Aur, bool handleEffects)
|
||||
for(;;)
|
||||
{
|
||||
Unit* caster = Aur->GetCaster();
|
||||
if(!caster) // caster deleted and not required adding scAura
|
||||
break;
|
||||
assert(caster);
|
||||
|
||||
bool restart = false;
|
||||
AuraList& scAuras = caster->GetSingleCastAuras();
|
||||
@@ -4251,7 +4250,7 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase)
|
||||
if (aura->GetTarget() != this && !aura->GetTarget()->InSamePhase(newPhase))
|
||||
{
|
||||
uint32 removedAuras = m_removedAurasCount;
|
||||
aura->GetTarget()->RemoveAura(aura->GetId(),aura->GetCasterGUID());
|
||||
aura->GetTarget()->RemoveAura(aura);
|
||||
if (removedAuras+1<m_removedAurasCount)
|
||||
iter=scAuras.begin();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user