Core/Spells: Rename confusing SpellState enum values

Port From (https://github.com/TrinityCore/TrinityCore/commit/2e79d3524f12a525c337c5ce8d84b793cacd6e91)
This commit is contained in:
Hondacrx
2025-08-11 19:52:08 -04:00
parent ceb78e5914
commit 2c9db326f6
7 changed files with 31 additions and 36 deletions
@@ -431,12 +431,12 @@ namespace Framework.Constants
public enum SpellState public enum SpellState
{ {
None = 0, Null = 0,
Preparing = 1, Preparing = 1,
Casting = 2, Launched = 2,
Finished = 3, Channeling = 3,
Idle = 4, Finished = 4,
Delayed = 5 Idle = 5
} }
public enum SpellSchools public enum SpellSchools
+3 -3
View File
@@ -1750,13 +1750,13 @@ namespace Game.Entities
RemoveOwnedAura(pair); RemoveOwnedAura(pair);
} }
// currently casted spells can be dependent from item // currently cast spells can be dependent from item
for (CurrentSpellTypes i = 0; i < CurrentSpellTypes.Max; ++i) for (CurrentSpellTypes i = 0; i < CurrentSpellTypes.Max; ++i)
{ {
Spell spell = GetCurrentSpell(i); Spell spell = GetCurrentSpell(i);
if (spell != null) if (spell != null)
if (spell.GetState() != SpellState.Delayed && !HasItemFitToSpellRequirements(spell.m_spellInfo, pItem)) if (!HasItemFitToSpellRequirements(spell.m_spellInfo, pItem))
InterruptSpell(i); InterruptSpell(i, false);
} }
} }
+9 -12
View File
@@ -981,7 +981,7 @@ namespace Game.Entities
} }
return null; return null;
}; }
SpellInfo newInfo = findMatchingAuraEffectIn(AuraType.OverrideActionbarSpells, ref triggerFlag); SpellInfo newInfo = findMatchingAuraEffectIn(AuraType.OverrideActionbarSpells, ref triggerFlag);
if (newInfo != null) if (newInfo != null)
@@ -1113,12 +1113,9 @@ namespace Game.Entities
public Spell FindCurrentSpellBySpellId(uint spell_id) public Spell FindCurrentSpellBySpellId(uint spell_id)
{ {
foreach (var spell in m_currentSpells.Values) foreach (var spell in m_currentSpells.Values)
{ if (spell != null && spell.m_spellInfo.Id == spell_id)
if (spell == null)
continue;
if (spell.m_spellInfo.Id == spell_id)
return spell; return spell;
}
return null; return null;
} }
@@ -1936,7 +1933,7 @@ namespace Game.Entities
// generic spells are cast when they are not finished and not delayed // generic spells are cast when they are not finished and not delayed
var currentSpell = GetCurrentSpell(CurrentSpellTypes.Generic); var currentSpell = GetCurrentSpell(CurrentSpellTypes.Generic);
if (currentSpell != null && (currentSpell.GetState() != SpellState.Finished) && (withDelayed || currentSpell.GetState() != SpellState.Delayed)) if (currentSpell != null && (currentSpell.GetState() != SpellState.Finished) && (withDelayed || currentSpell.GetState() != SpellState.Launched))
{ {
if (!skipInstant || currentSpell.GetCastTime() != 0) if (!skipInstant || currentSpell.GetCastTime() != 0)
{ {
@@ -2630,8 +2627,8 @@ namespace Game.Entities
Log.outDebug(LogFilter.Unit, "Interrupt spell for unit {0}", GetEntry()); Log.outDebug(LogFilter.Unit, "Interrupt spell for unit {0}", GetEntry());
Spell spell = m_currentSpells.LookupByKey(spellType); Spell spell = m_currentSpells.LookupByKey(spellType);
if (spell != null if (spell != null
&& (withDelayed || spell.GetState() != SpellState.Delayed) && (withDelayed || spell.GetState() != SpellState.Launched)
&& (withInstant || spell.GetCastTime() > 0 || spell.GetState() == SpellState.Casting)) && (withInstant || spell.GetCastTime() > 0 || spell.GetState() == SpellState.Channeling))
{ {
// for example, do not let self-stun aura interrupt itself // for example, do not let self-stun aura interrupt itself
if (!spell.IsInterruptable()) if (!spell.IsInterruptable())
@@ -2667,7 +2664,7 @@ namespace Game.Entities
Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled); Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled);
if (spell != null) if (spell != null)
{ {
if (spell.GetState() == SpellState.Casting) if (spell.GetState() == SpellState.Channeling)
{ {
m_interruptMask |= spell.m_spellInfo.ChannelInterruptFlags; m_interruptMask |= spell.m_spellInfo.ChannelInterruptFlags;
m_interruptMask2 |= spell.m_spellInfo.ChannelInterruptFlags2; m_interruptMask2 |= spell.m_spellInfo.ChannelInterruptFlags2;
@@ -3117,7 +3114,7 @@ namespace Game.Entities
Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled); Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled);
if (spell != null) if (spell != null)
{ {
if (spell.GetState() == SpellState.Casting if (spell.GetState() == SpellState.Channeling
&& spell.GetSpellInfo().HasChannelInterruptFlag(flag) && spell.GetSpellInfo().HasChannelInterruptFlag(flag)
&& (source == null || spell.GetSpellInfo().Id != source.Id) && (source == null || spell.GetSpellInfo().Id != source.Id)
&& !IsInterruptFlagIgnoredForSpell(flag, this, spell.GetSpellInfo(), true, source)) && !IsInterruptFlagIgnoredForSpell(flag, this, spell.GetSpellInfo(), true, source))
@@ -3150,7 +3147,7 @@ namespace Game.Entities
Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled); Spell spell = GetCurrentSpell(CurrentSpellTypes.Channeled);
if (spell != null) if (spell != null)
{ {
if (spell.GetState() == SpellState.Casting if (spell.GetState() == SpellState.Channeling
&& spell.GetSpellInfo().HasChannelInterruptFlag(flag) && spell.GetSpellInfo().HasChannelInterruptFlag(flag)
&& (source == null || spell.GetSpellInfo().Id != source.Id) && (source == null || spell.GetSpellInfo().Id != source.Id)
&& !IsInterruptFlagIgnoredForSpell(flag, this, spell.GetSpellInfo(), true, source)) && !IsInterruptFlagIgnoredForSpell(flag, this, spell.GetSpellInfo(), true, source))
+1 -1
View File
@@ -2939,7 +2939,7 @@ namespace Game.Entities
{ {
Spell spell1 = victim.GetCurrentSpell(CurrentSpellTypes.Channeled); Spell spell1 = victim.GetCurrentSpell(CurrentSpellTypes.Channeled);
if (spell1 != null) if (spell1 != null)
if (spell1.GetState() == SpellState.Casting && spell1.m_spellInfo.HasChannelInterruptFlag(SpellAuraInterruptFlags.DamageChannelDuration)) if (spell1.GetState() == SpellState.Channeling && spell1.m_spellInfo.HasChannelInterruptFlag(SpellAuraInterruptFlags.DamageChannelDuration))
spell1.DelayedChannel(); spell1.DelayedChannel();
} }
} }
+1 -1
View File
@@ -1917,7 +1917,7 @@ namespace Game.Spells
target.SetSilencedSchoolMask((SpellSchoolMask)GetMiscValue()); target.SetSilencedSchoolMask((SpellSchoolMask)GetMiscValue());
// call functions which may have additional effects after changing state of unit // call functions which may have additional effects after changing state of unit
// Stop cast only spells vs PreventionType & SPELL_PREVENTION_TYPE_SILENCE // Stop cast only spells vs PreventionType & SPELL_PREVENTION_TYPE_NO_ACTIONS
for (var i = CurrentSpellTypes.Melee; i < CurrentSpellTypes.Max; ++i) for (var i = CurrentSpellTypes.Melee; i < CurrentSpellTypes.Max; ++i)
{ {
Spell spell = target.GetCurrentSpell(i); Spell spell = target.GetCurrentSpell(i);
+11 -13
View File
@@ -2748,13 +2748,12 @@ namespace Game.Spells
{ {
case SpellState.Preparing: case SpellState.Preparing:
CancelGlobalCooldown(); CancelGlobalCooldown();
goto case SpellState.Delayed; goto case SpellState.Launched;
case SpellState.Delayed: case SpellState.Launched:
SendInterrupted(0); SendInterrupted(0);
SendCastResult(SpellCastResult.Interrupted); SendCastResult(SpellCastResult.Interrupted);
break; break;
case SpellState.Channeling:
case SpellState.Casting:
foreach (var ihit in m_UniqueTargetInfo) foreach (var ihit in m_UniqueTargetInfo)
{ {
if (ihit.MissCondition == SpellMissInfo.None) if (ihit.MissCondition == SpellMissInfo.None)
@@ -2771,7 +2770,6 @@ namespace Game.Spells
m_appliedMods.Clear(); m_appliedMods.Clear();
break; break;
default: default:
break; break;
} }
@@ -3054,7 +3052,7 @@ namespace Game.Spells
// Okay, maps created, now prepare flags // Okay, maps created, now prepare flags
m_immediateHandled = false; m_immediateHandled = false;
m_spellState = SpellState.Delayed; m_spellState = SpellState.Launched;
SetDelayStart(0); SetDelayStart(0);
unitCaster = m_caster.ToUnit(); unitCaster = m_caster.ToUnit();
@@ -3222,7 +3220,7 @@ namespace Game.Spells
if (duration != 0) if (duration != 0)
{ {
m_spellState = SpellState.Casting; m_spellState = SpellState.Channeling;
// GameObjects shouldn't cast channeled spells // GameObjects shouldn't cast channeled spells
m_caster.ToUnit()?.AddInterruptMask(m_spellInfo.ChannelInterruptFlags, m_spellInfo.ChannelInterruptFlags2); m_caster.ToUnit()?.AddInterruptMask(m_spellInfo.ChannelInterruptFlags, m_spellInfo.ChannelInterruptFlags2);
} }
@@ -3254,7 +3252,7 @@ namespace Game.Spells
// Remove used for cast item if need (it can be already NULL after TakeReagents call // Remove used for cast item if need (it can be already NULL after TakeReagents call
TakeCastItem(); TakeCastItem();
if (m_spellState != SpellState.Casting) if (m_spellState != SpellState.Channeling)
Finish(); // successfully finish spell cast (not last in case autorepeat or channel spell) Finish(); // successfully finish spell cast (not last in case autorepeat or channel spell)
} }
@@ -3472,7 +3470,7 @@ namespace Game.Spells
Cast(m_casttime == 0); Cast(m_casttime == 0);
break; break;
} }
case SpellState.Casting: case SpellState.Channeling:
{ {
if (m_timer != 0) if (m_timer != 0)
{ {
@@ -7287,7 +7285,7 @@ namespace Game.Spells
if (unitCaster == null) if (unitCaster == null)
return; return;
if (m_spellState != SpellState.Casting) if (m_spellState != SpellState.Channeling)
return; return;
if (IsDelayableNoMore()) // Spells may only be delayed twice if (IsDelayableNoMore()) // Spells may only be delayed twice
@@ -8415,7 +8413,7 @@ namespace Game.Spells
if (m_casttime > 0 && m_spellInfo.InterruptFlags.HasFlag(SpellInterruptFlags.Movement)) if (m_casttime > 0 && m_spellInfo.InterruptFlags.HasFlag(SpellInterruptFlags.Movement))
return SpellCastResult.Moving; return SpellCastResult.Moving;
} }
else if (GetState() == SpellState.Casting && !m_spellInfo.IsMoveAllowedChannel()) else if (GetState() == SpellState.Channeling && !m_spellInfo.IsMoveAllowedChannel())
return SpellCastResult.Moving; return SpellCastResult.Moving;
} }
} }
@@ -8909,7 +8907,7 @@ namespace Game.Spells
if (unit.IsAlive() != IsAlive && !spell.m_spellInfo.HasAttribute(SpellAttr9.ForceCorpseTarget)) if (unit.IsAlive() != IsAlive && !spell.m_spellInfo.HasAttribute(SpellAttr9.ForceCorpseTarget))
return; return;
if (!spell.m_spellInfo.HasAttribute(SpellAttr8.IgnoreSanctuary) && spell.GetState() == SpellState.Delayed && !spell.IsPositive() && (GameTime.GetGameTimeMS() - TimeDelay) <= unit.LastSanctuaryTime) if (!spell.m_spellInfo.HasAttribute(SpellAttr8.IgnoreSanctuary) && spell.GetState() == SpellState.Launched && !spell.IsPositive() && (GameTime.GetGameTimeMS() - TimeDelay) <= unit.LastSanctuaryTime)
return; // No missinfo in that case return; // No missinfo in that case
if (_spellHitTarget != null) if (_spellHitTarget != null)
@@ -9652,7 +9650,7 @@ namespace Game.Spells
// event will be re-added automatically at the end of routine) // event will be re-added automatically at the end of routine)
break; break;
} }
case SpellState.Delayed: case SpellState.Launched:
{ {
// first, check, if we have just started // first, check, if we have just started
if (m_Spell.GetDelayStart() != 0) if (m_Spell.GetDelayStart() != 0)
+1 -1
View File
@@ -2576,7 +2576,7 @@ namespace Game.Spells
{ {
SpellInfo curSpellInfo = spell.m_spellInfo; SpellInfo curSpellInfo = spell.m_spellInfo;
// check if we can interrupt spell // check if we can interrupt spell
if ((spell.GetState() == SpellState.Casting if ((spell.GetState() == SpellState.Channeling
|| (spell.GetState() == SpellState.Preparing && spell.GetCastTime() > 0.0f)) || (spell.GetState() == SpellState.Preparing && spell.GetCastTime() > 0.0f))
&& curSpellInfo.CanBeInterrupted(m_caster, unitTarget)) && curSpellInfo.CanBeInterrupted(m_caster, unitTarget))
{ {