Core/Items: Fixed crash in selecting azerite essences

Port From (https://github.com/TrinityCore/TrinityCore/commit/bec4ed0f16d100f74c76e4aca06ed9ea42e21ec4)
This commit is contained in:
hondacrx
2019-12-02 14:15:23 -05:00
parent cdb225a4b6
commit e24c69dd89
4 changed files with 67 additions and 51 deletions
+19 -10
View File
@@ -1234,21 +1234,30 @@ namespace Game.Entities
public virtual SpellInfo GetCastSpellInfo(SpellInfo spellInfo)
{
var swaps = GetAuraEffectsByType(AuraType.OverrideActionbarSpells);
var swaps2 = GetAuraEffectsByType(AuraType.OverrideActionbarSpellsTriggered);
if (!swaps2.Empty())
swaps.AddRange(swaps2);
foreach (AuraEffect auraEffect in swaps)
SpellInfo findMatchingAuraEffectIn(AuraType type)
{
if (auraEffect.GetMiscValue() == spellInfo.Id || auraEffect.IsAffectingSpell(spellInfo))
foreach (AuraEffect auraEffect in GetAuraEffectsByType(type))
{
SpellInfo newInfo = Global.SpellMgr.GetSpellInfo((uint)auraEffect.GetAmount());
if (newInfo != null)
return newInfo;
bool matches = auraEffect.GetMiscValue() != 0 ? auraEffect.GetMiscValue() == spellInfo.Id : auraEffect.IsAffectingSpell(spellInfo);
if (matches)
{
SpellInfo info = Global.SpellMgr.GetSpellInfo((uint)auraEffect.GetAmount());
if (info != null)
return info;
}
}
return null;
}
SpellInfo newInfo = findMatchingAuraEffectIn(AuraType.OverrideActionbarSpells);
if (newInfo != null)
return newInfo;
newInfo = findMatchingAuraEffectIn(AuraType.OverrideActionbarSpellsTriggered);
if (newInfo != null)
return newInfo;
return spellInfo;
}