From dc6545a6521840c8d84e3387af262cb569f4a7d3 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 2 Oct 2021 19:52:58 -0400 Subject: [PATCH] Core/Commands: Lookup spell command fixes Port From (https://github.com/TrinityCore/TrinityCore/commit/a098137b59944bd45794d92200e3433d25e2515b) --- Source/Game/Chat/Commands/LookupCommands.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Source/Game/Chat/Commands/LookupCommands.cs b/Source/Game/Chat/Commands/LookupCommands.cs index c45cc481c..b79ed6fe6 100644 --- a/Source/Game/Chat/Commands/LookupCommands.cs +++ b/Source/Game/Chat/Commands/LookupCommands.cs @@ -1121,10 +1121,9 @@ namespace Game.Chat } bool known = target && target.HasSpell(spellInfo.Id); - SpellEffectInfo spellEffectInfo = spellInfo.GetEffect(0); - bool learn = spellEffectInfo.Effect == SpellEffectName.LearnSpell; + var spellEffectInfo = spellInfo.GetEffects().Find(spelleffectInfo => spelleffectInfo.IsEffect(SpellEffectName.LearnSpell)); - SpellInfo learnSpellInfo = Global.SpellMgr.GetSpellInfo(spellEffectInfo.TriggerSpell, spellInfo.Difficulty); + SpellInfo learnSpellInfo = spellEffectInfo != null ? Global.SpellMgr.GetSpellInfo(spellEffectInfo.TriggerSpell, spellInfo.Difficulty) : null; bool talent = spellInfo.HasAttribute(SpellCustomAttributes.IsTalent); bool passive = spellInfo.IsPassive(); @@ -1132,7 +1131,7 @@ namespace Game.Chat // unit32 used to prevent interpreting public byte as char at output // find rank of learned spell for learning spell, or talent rank - uint rank = learn && learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank(); + uint rank = learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank(); // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format StringBuilder ss = new(); @@ -1152,7 +1151,7 @@ namespace Game.Chat ss.Append(handler.GetCypherString(CypherStrings.Talent)); if (passive) ss.Append(handler.GetCypherString(CypherStrings.Passive)); - if (learn) + if (learnSpellInfo != null) ss.Append(handler.GetCypherString(CypherStrings.Learn)); if (known) ss.Append(handler.GetCypherString(CypherStrings.Known)); @@ -1195,8 +1194,7 @@ namespace Game.Chat } bool known = target && target.HasSpell(id); - SpellEffectInfo spellEffectInfo = spellInfo.GetEffect(0); - bool learn = spellEffectInfo.Effect == SpellEffectName.LearnSpell; + var spellEffectInfo = spellInfo.GetEffects().Find(spelleffectInfo => spelleffectInfo.IsEffect(SpellEffectName.LearnSpell)); SpellInfo learnSpellInfo = Global.SpellMgr.GetSpellInfo(spellEffectInfo.TriggerSpell, Difficulty.None); @@ -1206,7 +1204,7 @@ namespace Game.Chat // unit32 used to prevent interpreting public byte as char at output // find rank of learned spell for learning spell, or talent rank - uint rank = learn && learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank(); + uint rank = learnSpellInfo != null ? learnSpellInfo.GetRank() : spellInfo.GetRank(); // send spell in "id - [name, rank N] [talent] [passive] [learn] [known]" format StringBuilder ss = new(); @@ -1226,7 +1224,7 @@ namespace Game.Chat ss.Append(handler.GetCypherString(CypherStrings.Talent)); if (passive) ss.Append(handler.GetCypherString(CypherStrings.Passive)); - if (learn) + if (learnSpellInfo != null) ss.Append(handler.GetCypherString(CypherStrings.Learn)); if (known) ss.Append(handler.GetCypherString(CypherStrings.Known));