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
+10 -10
View File
@@ -167,14 +167,14 @@ namespace Game.Entities
selectedEssences.ModifyValue(selectedEssences.AzeriteEssenceID, i) = selectedEssenceData.AzeriteEssenceId[i];
}
if (owner.GetPrimarySpecialization() == selectedEssenceData.SpecializationId)
if (owner != null && owner.GetPrimarySpecialization() == selectedEssenceData.SpecializationId)
selectedEssences.ModifyValue(selectedEssences.Enabled).SetValue(1);
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.SelectedEssences), selectedEssences);
}
// add selected essences for current spec
if (GetSelectedAzeriteEssences() == null)
if (owner != null && GetSelectedAzeriteEssences() == null)
CreateSelectedAzeriteEssences(owner.GetPrimarySpecialization());
if (needSave)
@@ -372,6 +372,14 @@ namespace Game.Entities
return null;
}
public void CreateSelectedAzeriteEssences(uint specializationId)
{
SelectedAzeriteEssences selectedEssences = new SelectedAzeriteEssences();
selectedEssences.ModifyValue(selectedEssences.SpecializationID).SetValue(specializationId);
selectedEssences.ModifyValue(selectedEssences.Enabled).SetValue(1);
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.SelectedEssences), selectedEssences);
}
public void SetSelectedAzeriteEssences(uint specializationId)
{
int index = m_azeriteItemData.SelectedEssences.FindIndexIf(essences => { return essences.Enabled == 1; });
@@ -487,14 +495,6 @@ namespace Game.Entities
hasPreviousMilestone = false;
}
}
void CreateSelectedAzeriteEssences(uint specializationId)
{
var selectedEssences = new SelectedAzeriteEssences();
selectedEssences.ModifyValue(selectedEssences.SpecializationID).SetValue(specializationId);
selectedEssences.ModifyValue(selectedEssences.Enabled).SetValue(1);
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.SelectedEssences), selectedEssences);
}
}
public class AzeriteItemSelectedEssencesData
+2 -2
View File
@@ -570,7 +570,7 @@ namespace Game.Entities
if (artifactPowerPicker != null)
{
PlayerConditionRecord playerCondition = CliDB.PlayerConditionStorage.LookupByKey(artifactPowerPicker.PlayerConditionID);
if (playerCondition == null || ConditionManager.IsPlayerMeetingCondition(owner, playerCondition))
if (playerCondition == null || (owner != null && ConditionManager.IsPlayerMeetingCondition(owner, playerCondition)))
if (artifactPower.Label == _bonusData.GemRelicType[e - EnchantmentSlot.Sock1])
power.CurrentRankWithBonus += (byte)enchant.EffectPointsMin[i];
}
@@ -595,7 +595,7 @@ namespace Game.Entities
SetArtifactPower((ushort)power.ArtifactPowerId, power.PurchasedRank, (byte)(totalPurchasedRanks + 1));
}
CheckArtifactRelicSlotUnlock(owner != null ? owner : GetOwner());
CheckArtifactRelicSlotUnlock(owner);
}
public void CheckArtifactRelicSlotUnlock(Player owner)
+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;
}