Core/Spells: Rename confusing SpellState enum values

* SPELL_STATE_CASTING -> SPELL_STATE_CHANNELING (was used for "channel in progress")
* SPELL_STATE_DELAYED -> SPELL_STATE_LAUNCHED
This commit is contained in:
Shauren authored and Ovahlord committed 2025-08-02 12:37:52 +02:00
1 parent c550e2d29f
commit 78de91a487
8 files changed
+39 -43

No files matched your search

+2 -2
View File
@@ -24108,8 +24108,8 @@ void Player::RemoveItemDependentAurasAndCasts(Item* pItem)
// currently cast spells can be dependent from item
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
if (Spell* spell = GetCurrentSpell(CurrentSpellTypes(i)))
if (spell->getState() != SPELL_STATE_DELAYED && !HasItemFitToSpellRequirements(spell->m_spellInfo, pItem))
InterruptSpell(CurrentSpellTypes(i));
if (!HasItemFitToSpellRequirements(spell->m_spellInfo, pItem))
InterruptSpell(CurrentSpellTypes(i), false);
}
uint32 Player::GetResurrectionSpellId()
+13 -12
View File
@@ -695,7 +695,7 @@ void Unit::UpdateInterruptMask()
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
{
if (spell->getState() == SPELL_STATE_CASTING)
if (spell->getState() == SPELL_STATE_CHANNELING)
{
m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags;
m_interruptMask2 |= spell->m_spellInfo->ChannelInterruptFlags2;
@@ -978,7 +978,7 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons
if (damage && victim->IsPlayer())
if (Spell* spell = victim->m_currentSpells[CURRENT_CHANNELED_SPELL])
if (spell->getState() == SPELL_STATE_CASTING && spell->m_spellInfo->HasChannelInterruptFlag(SpellAuraInterruptFlags::DamageChannelDuration))
if (spell->getState() == SPELL_STATE_CHANNELING && spell->m_spellInfo->HasChannelInterruptFlag(SpellAuraInterruptFlags::DamageChannelDuration))
spell->DelayedChannel();
}
}
@@ -2648,12 +2648,12 @@ void Unit::_UpdateSpells(uint32 time)
_UpdateAutoRepeatSpell();
// remove finished spells from current pointers
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
for (Spell*& spell : m_currentSpells)
{
if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
if (spell && spell->getState() == SPELL_STATE_FINISHED)
{
m_currentSpells[i]->SetReferencedFromCurrent(false);
m_currentSpells[i] = nullptr; // remove pointer
spell->SetReferencedFromCurrent(false);
spell = nullptr; // remove pointer
}
}
@@ -2812,7 +2812,8 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi
if (!spell)
return;
if ((withDelayed || spell->getState() != SPELL_STATE_DELAYED) && (withInstant || spell->GetCastTime() > 0 || spell->getState() == SPELL_STATE_CASTING))
if ((withDelayed || spell->getState() != SPELL_STATE_LAUNCHED) &&
(withInstant || spell->GetCastTime() > 0 || spell->getState() == SPELL_STATE_CHANNELING))
{
// for example, do not let self-stun aura interrupt itself
if (!spell->IsInterruptable())
@@ -2856,7 +2857,7 @@ bool Unit::IsNonMeleeSpellCast(bool withDelayed, bool skipChanneled, bool skipAu
// generic spells are cast when they are not finished and not delayed
if (m_currentSpells[CURRENT_GENERIC_SPELL] &&
(m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_FINISHED) &&
(withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_DELAYED))
(withDelayed || m_currentSpells[CURRENT_GENERIC_SPELL]->getState() != SPELL_STATE_LAUNCHED))
{
if (!skipInstant || m_currentSpells[CURRENT_GENERIC_SPELL]->GetCastTime())
{
@@ -2895,9 +2896,9 @@ void Unit::InterruptNonMeleeSpells(bool withDelayed, uint32 spell_id, bool withI
Spell* Unit::FindCurrentSpellBySpellId(uint32 spell_id) const
{
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
if (m_currentSpells[i] && m_currentSpells[i]->m_spellInfo->Id == spell_id)
return m_currentSpells[i];
for (Spell* spell : m_currentSpells)
if (spell && spell->m_spellInfo->Id == spell_id)
return spell;
return nullptr;
}
@@ -3872,7 +3873,7 @@ void Unit::RemoveAurasWithInterruptFlags(InterruptFlags flag, SpellInfo const* s
// interrupt channeled spell
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
if (spell->getState() == SPELL_STATE_CASTING
if (spell->getState() == SPELL_STATE_CHANNELING
&& spell->GetSpellInfo()->HasChannelInterruptFlag(flag)
&& (!source || spell->GetSpellInfo()->Id != source->Id)
&& !IsInterruptFlagIgnoredForSpell(flag, this, spell->GetSpellInfo(), source))
@@ -2614,7 +2614,7 @@ void AuraEffect::HandleAuraModNoActions(AuraApplication const* aurApp, uint8 mod
target->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_NO_ACTIONS);
// call functions which may have additional effects after chainging 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 (uint32 i = CURRENT_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i)
if (Spell* spell = target->GetCurrentSpell(CurrentSpellTypes(i)))
if (spell->m_spellInfo->PreventionType == SPELL_PREVENTION_TYPE_NO_ACTIONS)
+11 -11
View File
@@ -2619,7 +2619,7 @@ void Spell::TargetInfo::DoTargetSpellHit(Spell* spell, uint8 effIndex)
if (unit->IsAlive() != IsAlive)
return;
if (!spell->m_spellInfo->HasAttribute(SPELL_ATTR8_IGNORE_SANCTUARY) && spell->getState() == SPELL_STATE_DELAYED && !spell->IsPositive() && (GameTime::GetGameTimeMS() - TimeDelay) <= unit->m_lastSanctuaryTime)
if (!spell->m_spellInfo->HasAttribute(SPELL_ATTR8_IGNORE_SANCTUARY) && spell->getState() == SPELL_STATE_LAUNCHED && !spell->IsPositive() && (GameTime::GetGameTimeMS() - TimeDelay) <= unit->m_lastSanctuaryTime)
return; // No missinfo in that case
if (_spellHitTarget)
@@ -3509,7 +3509,7 @@ void Spell::cancel()
if (m_spellState == SPELL_STATE_FINISHED)
return;
uint32 oldState = m_spellState;
SpellState oldState = m_spellState;
m_spellState = SPELL_STATE_FINISHED;
m_autoRepeat = false;
@@ -3518,11 +3518,11 @@ void Spell::cancel()
case SPELL_STATE_PREPARING:
CancelGlobalCooldown();
[[fallthrough]];
case SPELL_STATE_DELAYED:
case SPELL_STATE_LAUNCHED:
SendInterrupted(0);
SendCastResult(SPELL_FAILED_INTERRUPTED);
break;
case SPELL_STATE_CASTING:
case SPELL_STATE_CHANNELING:
for (TargetInfo const& targetInfo : m_UniqueTargetInfo)
if (targetInfo.MissCondition == SPELL_MISS_NONE)
if (Unit* unit = m_caster->GetGUID() == targetInfo.TargetGUID ? m_caster->ToUnit() : ObjectAccessor::GetUnit(*m_caster, targetInfo.TargetGUID))
@@ -3774,7 +3774,7 @@ void Spell::_cast(bool skipCheck)
// Okay, maps created, now prepare flags
m_immediateHandled = false;
m_spellState = SPELL_STATE_DELAYED;
m_spellState = SPELL_STATE_LAUNCHED;
SetDelayStart(0);
if (Unit* unitCaster = m_caster->ToUnit())
@@ -3889,7 +3889,7 @@ void Spell::handle_immediate()
if (duration != 0)
{
m_spellState = SPELL_STATE_CASTING;
m_spellState = SPELL_STATE_CHANNELING;
// GameObjects shouldn't cast channeled spells
ASSERT_NOTNULL(m_caster->ToUnit())->AddInterruptMask(m_spellInfo->ChannelInterruptFlags, m_spellInfo->ChannelInterruptFlags2);
}
@@ -3917,7 +3917,7 @@ void Spell::handle_immediate()
// Remove used for cast item if need (it can be already nullptr after TakeReagents call
TakeCastItem();
if (m_spellState != SPELL_STATE_CASTING)
if (m_spellState != SPELL_STATE_CHANNELING)
finish(true); // successfully finish spell cast (not last in case autorepeat or channel spell)
}
@@ -4166,7 +4166,7 @@ void Spell::update(uint32 difftime)
cast(!m_casttime);
break;
}
case SPELL_STATE_CASTING:
case SPELL_STATE_CHANNELING:
{
if (m_timer)
{
@@ -6888,7 +6888,7 @@ SpellCastResult Spell::CheckMovement() const
if (m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::Movement))
return SPELL_FAILED_MOVING;
}
else if (getState() == SPELL_STATE_CASTING)
else if (getState() == SPELL_STATE_CHANNELING)
if (!m_spellInfo->IsMoveAllowedChannel())
return SPELL_FAILED_MOVING;
}
@@ -7664,7 +7664,7 @@ void Spell::DelayedChannel()
if (!playerCaster)
return;
if (m_spellState != SPELL_STATE_CASTING)
if (m_spellState != SPELL_STATE_CHANNELING)
return;
if (IsDelayableNoMore()) // Spells may only be delayed twice
@@ -7965,7 +7965,7 @@ bool SpellEvent::Execute(uint64 e_time, uint32 p_time)
// event will be re-added automatically at the end of routine)
break;
}
case SPELL_STATE_DELAYED:
case SPELL_STATE_LAUNCHED:
{
// first, check, if we have just started
if (m_Spell->GetDelayStart() != 0)
+9 -9
View File
@@ -259,12 +259,12 @@ struct SpellValue
enum SpellState
{
SPELL_STATE_NULL = 0,
SPELL_STATE_PREPARING = 1,
SPELL_STATE_CASTING = 2,
SPELL_STATE_FINISHED = 3,
SPELL_STATE_IDLE = 4,
SPELL_STATE_DELAYED = 5
SPELL_STATE_NULL = 0,
SPELL_STATE_PREPARING = 1,
SPELL_STATE_LAUNCHED = 2,
SPELL_STATE_CHANNELING = 3,
SPELL_STATE_FINISHED = 4,
SPELL_STATE_IDLE = 5
};
enum SpellEffectHandleMode
@@ -494,8 +494,8 @@ class TC_GAME_API Spell
void Delayed();
void DelayedChannel();
uint32 getState() const { return m_spellState; }
void setState(uint32 state) { m_spellState = state; }
SpellState getState() const { return m_spellState; }
void setState(SpellState state) { m_spellState = state; }
void DoCreateItem(uint32 i, uint32 itemtype);
@@ -822,7 +822,7 @@ class TC_GAME_API Spell
SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue);
// -------------------------------------------
uint32 m_spellState;
SpellState m_spellState;
int32 m_timer;
SpellEvent* _spellEvent;
+1 -1
View File
@@ -2937,7 +2937,7 @@ void Spell::EffectInterruptCast(SpellEffIndex effIndex)
{
SpellInfo const* curSpellInfo = spell->m_spellInfo;
// check if we can interrupt spell
if ((spell->getState() == SPELL_STATE_CASTING
if ((spell->getState() == SPELL_STATE_CHANNELING
|| (spell->getState() == SPELL_STATE_PREPARING && spell->GetCastTime() > 0.0f))
&& curSpellInfo->CanBeInterrupted(unitTarget))
{
@@ -2429,7 +2429,7 @@ class spell_yogg_saron_diminsh_power : public SpellScriptLoader // 64148
{
PreventDefaultAction();
if (Spell* spell = GetTarget()->GetCurrentSpell(CURRENT_CHANNELED_SPELL))
if (spell->getState() == SPELL_STATE_CASTING)
if (spell->getState() == SPELL_STATE_CHANNELING)
GetTarget()->InterruptSpell(CURRENT_CHANNELED_SPELL);
}
@@ -792,12 +792,7 @@ public:
{
if (Player* i_pl = itr->GetSource())
{
bool isCasting = false;
for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
if (i_pl->GetCurrentSpell(i))
isCasting = true;
if (isCasting)
if (i_pl->IsNonMeleeSpellCast(false, false, true))
{
DoCast(i_pl, SPELL_EARTHSHOCK);
break;