From b530251d6c68f25fdd807b4ea24d6cc96b2f0167 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 8 Sep 2021 23:31:13 -0400 Subject: [PATCH] Core/Spells: Avoid static analysis false positive Port From (https://github.com/TrinityCore/TrinityCore/commit/add2e6d212b356347241bfd1b52b37a447df74ce) --- Source/Game/Spells/Spell.cs | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 16b2b228a..bb20424a6 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -3624,30 +3624,19 @@ namespace Game.Spells { castData.RemainingRunes.HasValue = true; RuneData runeData = castData.RemainingRunes.Value; - //TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature - //The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster + Player player = m_caster.ToPlayer(); - if (player) + runeData.Start = m_runesState; // runes state before + runeData.Count = player.GetRunesState(); // runes state after + for (byte i = 0; i < player.GetMaxPower(PowerType.Runes); ++i) { - runeData.Start = m_runesState; // runes state before - runeData.Count = player.GetRunesState(); // runes state after - for (byte i = 0; i < player.GetMaxPower(PowerType.Runes); ++i) - { - // float casts ensure the division is performed on floats as we need float result - float baseCd = player.GetRuneBaseCooldown(); - runeData.Cooldowns.Add((byte)((baseCd - player.GetRuneCooldown(i)) / baseCd * 255)); // rune cooldown passed - } - } - else - { - runeData.Start = 0; - runeData.Count = 0; - for (byte i = 0; i < player.GetMaxPower(PowerType.Runes); ++i) - runeData.Cooldowns.Add(0); + // float casts ensure the division is performed on floats as we need float result + float baseCd = (float)player.GetRuneBaseCooldown(); + runeData.Cooldowns.Add((byte)((baseCd - (float)player.GetRuneCooldown(i)) / baseCd * 255)); // rune cooldown passed } } - if (Convert.ToBoolean(castFlags & SpellCastFlags.AdjustMissile)) + if (castFlags.HasFlag(SpellCastFlags.AdjustMissile)) { castData.MissileTrajectory.TravelTime = (uint)m_delayMoment; castData.MissileTrajectory.Pitch = m_targets.GetPitch(); @@ -3655,7 +3644,6 @@ namespace Game.Spells packet.LogData.Initialize(this); - m_caster.SendCombatLogMessage(packet); }