From 7cc02214476f11803681f7e1eae8879d2b77410e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 9 Aug 2021 10:05:13 -0400 Subject: [PATCH] Core/Entities: kill unused return value from Unit::HandleSpellClick Port From (https://github.com/TrinityCore/TrinityCore/commit/a1a00f823e7e47e8cb652b71a839c1d0875a8f84) --- Source/Game/AI/CoreAI/CreatureAI.cs | 2 +- Source/Game/AI/SmartScripts/SmartAI.cs | 4 ++-- Source/Game/Entities/Player/Player.Quest.cs | 6 +++--- Source/Game/Entities/Player/Player.Spells.cs | 6 +++--- Source/Game/Entities/Unit/Unit.Spells.cs | 14 ++++++-------- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/Source/Game/AI/CoreAI/CreatureAI.cs b/Source/Game/AI/CoreAI/CreatureAI.cs index b56e4f101..f2b5e7337 100644 --- a/Source/Game/AI/CoreAI/CreatureAI.cs +++ b/Source/Game/AI/CoreAI/CreatureAI.cs @@ -470,7 +470,7 @@ namespace Game.AI public virtual void PassengerBoarded(Unit passenger, sbyte seatId, bool apply) { } - public virtual void OnSpellClick(Unit clicker, ref bool result) { } + public virtual void OnSpellClick(Unit clicker, ref bool spellClickHandled) { } public virtual bool CanSeeAlways(WorldObject obj) { return false; } diff --git a/Source/Game/AI/SmartScripts/SmartAI.cs b/Source/Game/AI/SmartScripts/SmartAI.cs index 8276c85ea..7456fa3cf 100644 --- a/Source/Game/AI/SmartScripts/SmartAI.cs +++ b/Source/Game/AI/SmartScripts/SmartAI.cs @@ -895,9 +895,9 @@ namespace Game.AI GetScript().ProcessEventsFor(start ? SmartEvents.GameEventStart : SmartEvents.GameEventEnd, null, eventId); } - public override void OnSpellClick(Unit clicker, ref bool result) + public override void OnSpellClick(Unit clicker, ref bool spellClickHandled) { - if (!result) + if (!spellClickHandled) return; GetScript().ProcessEventsFor(SmartEvents.OnSpellclick, clicker); diff --git a/Source/Game/Entities/Player/Player.Quest.cs b/Source/Game/Entities/Player/Player.Quest.cs index 0702277d3..091a4ae52 100644 --- a/Source/Game/Entities/Player/Player.Quest.cs +++ b/Source/Game/Entities/Player/Player.Quest.cs @@ -2900,12 +2900,12 @@ namespace Game.Entities if (!obj.HasNpcFlag(NPCFlags.SpellClick)) continue; - var clickPair = Global.ObjectMgr.GetSpellClickInfoMapBounds(obj.GetEntry()); - foreach (var spell in clickPair) + var clickBounds = Global.ObjectMgr.GetSpellClickInfoMapBounds(obj.GetEntry()); + foreach (var spellClickInfo in clickBounds) { //! This code doesn't look right, but it was logically converted to condition system to do the exact //! same thing it did before. It definitely needs to be overlooked for intended functionality. - List conds = Global.ConditionMgr.GetConditionsForSpellClickEvent(obj.GetEntry(), spell.spellId); + List conds = Global.ConditionMgr.GetConditionsForSpellClickEvent(obj.GetEntry(), spellClickInfo.spellId); if (conds != null) { bool buildUpdateBlock = false; diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 4258eba2c..c8b1c7003 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -251,11 +251,11 @@ namespace Game.Entities if (!creature.HasNpcFlag(NPCFlags.SpellClick)) return false; - var clickPair = Global.ObjectMgr.GetSpellClickInfoMapBounds(creature.GetEntry()); - if (clickPair.Empty()) + var clickBounds = Global.ObjectMgr.GetSpellClickInfoMapBounds(creature.GetEntry()); + if (clickBounds.Empty()) return false; - foreach (var spellClickInfo in clickPair) + foreach (var spellClickInfo in clickBounds) { if (!spellClickInfo.IsFitToRequirements(this, creature)) return false; diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 7867674a3..dd8ae9704 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -2895,15 +2895,15 @@ namespace Game.Entities return null; } - public bool HandleSpellClick(Unit clicker, sbyte seatId = -1) + public void HandleSpellClick(Unit clicker, sbyte seatId = -1) { - bool result = false; + bool spellClickHandled = false; uint spellClickEntry = GetVehicleKit() != null ? GetVehicleKit().GetCreatureEntry() : GetEntry(); TriggerCastFlags flags = GetVehicleKit() ? TriggerCastFlags.IgnoreCasterMountedOrOnVehicle : TriggerCastFlags.None; - var clickPair = Global.ObjectMgr.GetSpellClickInfoMapBounds(spellClickEntry); - foreach (var clickInfo in clickPair) + var clickBounds = Global.ObjectMgr.GetSpellClickInfoMapBounds(spellClickEntry); + foreach (var clickInfo in clickBounds) { //! First check simple relations from clicker to clickee if (!clickInfo.IsFitToRequirements(clicker, this)) @@ -2971,14 +2971,12 @@ namespace Game.Entities Aura.TryRefreshStackOrCreate(spellEntry, ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, GetMapId(), spellEntry.Id, GetMap().GenerateLowGuid(HighGuid.Cast)), SpellConst.MaxEffectMask, this, clicker, GetMap().GetDifficultyID(), null, null, origCasterGUID); } - result = true; + spellClickHandled = true; } Creature creature = ToCreature(); if (creature && creature.IsAIEnabled) - creature.GetAI().OnSpellClick(clicker, ref result); - - return result; + creature.GetAI().OnSpellClick(clicker, ref spellClickHandled); } public bool HasAura(uint spellId, ObjectGuid casterGUID = default, ObjectGuid itemCasterGUID = default, uint reqEffMask = 0)