mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-13 09:17:18 +00:00
fix(Core/Unit): potential crash + extract duplicated code (#5303)
This commit is contained in:
@@ -11241,25 +11241,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
|
|||||||
if (spellProto->ValidateAttribute6SpellDamageMods(caster, *i, damagetype == DOT))
|
if (spellProto->ValidateAttribute6SpellDamageMods(caster, *i, damagetype == DOT))
|
||||||
AddPct(TakenTotalMod, (*i)->GetAmount());
|
AddPct(TakenTotalMod, (*i)->GetAmount());
|
||||||
|
|
||||||
// .. taken pct: dummy auras
|
TakenTotalMod = processDummyAuras(TakenTotalMod);
|
||||||
AuraEffectList const& mDummyAuras = GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
|
||||||
for (AuraEffectList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
|
|
||||||
{
|
|
||||||
switch ((*i)->GetSpellInfo()->SpellIconID)
|
|
||||||
{
|
|
||||||
// Cheat Death
|
|
||||||
case 2109:
|
|
||||||
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
|
||||||
{
|
|
||||||
// Patch 2.4.3: The resilience required to reach the 90% damage reduction cap
|
|
||||||
// is 22.5% critical strike damage reduction, or 444 resilience.
|
|
||||||
// To calculate for 90%, we multiply the 100% by 4 (22.5% * 4 = 90%)
|
|
||||||
float mod = -1.0f * GetMeleeCritDamageReduction(400);
|
|
||||||
AddPct(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// From caster spells
|
// From caster spells
|
||||||
if (caster)
|
if (caster)
|
||||||
@@ -11354,6 +11336,41 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui
|
|||||||
return uint32(std::max(tmpDamage, 0.0f));
|
return uint32(std::max(tmpDamage, 0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Unit::processDummyAuras(float TakenTotalMod) const
|
||||||
|
{
|
||||||
|
// note: old code coming from TC, just extracted here to remove the code duplication + solve potential crash
|
||||||
|
// see: https://github.com/TrinityCore/TrinityCore/commit/c85710e148d75450baedf6632b9ca6fd40b4148e
|
||||||
|
|
||||||
|
// .. taken pct: dummy auras
|
||||||
|
auto const& mDummyAuras = GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
||||||
|
for (auto i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
|
||||||
|
{
|
||||||
|
if (!(*i) || !(*i)->GetSpellInfo())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto spellIconId = (*i)->GetSpellInfo()->SpellIconID)
|
||||||
|
{
|
||||||
|
switch (spellIconId)
|
||||||
|
{
|
||||||
|
// Cheat Death
|
||||||
|
case 2109:
|
||||||
|
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
||||||
|
{
|
||||||
|
// Patch 2.4.3: The resilience required to reach the 90% damage reduction cap
|
||||||
|
// is 22.5% critical strike damage reduction, or 444 resilience.
|
||||||
|
// To calculate for 90%, we multiply the 100% by 4 (22.5% * 4 = 90%)
|
||||||
|
float mod = -1.0f * GetMeleeCritDamageReduction(400);
|
||||||
|
AddPct(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TakenTotalMod;
|
||||||
|
}
|
||||||
|
|
||||||
int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
|
int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask)
|
||||||
{
|
{
|
||||||
int32 DoneAdvertisedBenefit = 0;
|
int32 DoneAdvertisedBenefit = 0;
|
||||||
@@ -12591,25 +12608,7 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* attacker, uint32 pdamage, WeaponAttackT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// .. taken pct: dummy auras
|
TakenTotalMod = processDummyAuras(TakenTotalMod);
|
||||||
AuraEffectList const& mDummyAuras = GetAuraEffectsByType(SPELL_AURA_DUMMY);
|
|
||||||
for (AuraEffectList::const_iterator i = mDummyAuras.begin(); i != mDummyAuras.end(); ++i)
|
|
||||||
{
|
|
||||||
switch ((*i)->GetSpellInfo()->SpellIconID)
|
|
||||||
{
|
|
||||||
// Cheat Death
|
|
||||||
case 2109:
|
|
||||||
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
|
||||||
{
|
|
||||||
// Patch 2.4.3: The resilience required to reach the 90% damage reduction cap
|
|
||||||
// is 22.5% critical strike damage reduction, or 444 resilience.
|
|
||||||
// To calculate for 90%, we multiply the 100% by 4 (22.5% * 4 = 90%)
|
|
||||||
float mod = -1.0f * GetMeleeCritDamageReduction(400);
|
|
||||||
AddPct(TakenTotalMod, std::max(mod, float((*i)->GetAmount())));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// .. taken pct: class scripts
|
// .. taken pct: class scripts
|
||||||
/*AuraEffectList const& mclassScritAuras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
/*AuraEffectList const& mclassScritAuras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
||||||
|
|||||||
@@ -2620,6 +2620,8 @@ private:
|
|||||||
|
|
||||||
uint32 _oldFactionId; ///< faction before charm
|
uint32 _oldFactionId; ///< faction before charm
|
||||||
bool m_petCatchUp;
|
bool m_petCatchUp;
|
||||||
|
|
||||||
|
float processDummyAuras(float TakenTotalMod) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace acore
|
namespace acore
|
||||||
|
|||||||
Reference in New Issue
Block a user