From 012d6fa865fb8083dcbeae9b04926527b3c19f4e Mon Sep 17 00:00:00 2001 From: megamage Date: Wed, 19 Aug 2009 16:52:51 -0500 Subject: [8381] Some refactoring work in Unit::m_currentSpells code. Author: VladimirMangos * Restrict access, use enum args, move some repeated code parts to function. * Make m_selfContainer set only part of Unit::SetCurrentCastedSpell --HG-- branch : trunk --- src/game/Unit.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/game/Unit.h') diff --git a/src/game/Unit.h b/src/game/Unit.h index bb6b4262549..a0b371a2b7e 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -852,14 +852,16 @@ struct DeclinedName enum CurrentSpellTypes { - CURRENT_MELEE_SPELL = 0, - CURRENT_FIRST_NON_MELEE_SPELL = 1, // just counter - CURRENT_GENERIC_SPELL = 1, - CURRENT_AUTOREPEAT_SPELL = 2, - CURRENT_CHANNELED_SPELL = 3, - CURRENT_MAX_SPELL = 4 // just counter + CURRENT_MELEE_SPELL = 0, + CURRENT_GENERIC_SPELL = 1, + CURRENT_AUTOREPEAT_SPELL = 2, + CURRENT_CHANNELED_SPELL = 3 }; +#define CURRENT_FIRST_NON_MELEE_SPELL 1 +#define CURRENT_MAX_SPELL 4 + + enum ActiveStates { ACT_PASSIVE = 0x01, // 0x01 - passive @@ -1490,7 +1492,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void SetCurrentCastedSpell(Spell * pSpell); virtual void ProhibitSpellScholl(SpellSchoolMask /*idSchoolMask*/, uint32 /*unTimeMs*/ ) { } - void InterruptSpell(uint32 spellType, bool withDelayed = true, bool withInstant = true); + void InterruptSpell(CurrentSpellTypes spellType, bool withDelayed = true, bool withInstant = true); + void FinishSpell(CurrentSpellTypes spellType, bool ok = true); // set withDelayed to true to account delayed spells as casted // delayed+channeled spells are always accounted as casted @@ -1501,11 +1504,11 @@ class TRINITY_DLL_SPEC Unit : public WorldObject // delayed+channeled spells are always interrupted void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid = 0, bool withInstant = true); + Spell* GetCurrentSpell(CurrentSpellTypes spellType) const { return m_currentSpells[spellType]; } + Spell* GetCurrentSpell(uint32 spellType) const { return m_currentSpells[spellType]; } Spell* FindCurrentSpellBySpellId(uint32 spell_id) const; int32 GetCurrentSpellCastTime(uint32 spell_id) const; - Spell* m_currentSpells[CURRENT_MAX_SPELL]; - uint32 m_addDmgOnce; uint64 m_SummonSlot[MAX_SUMMON_SLOT]; uint64 m_ObjectSlot[4]; @@ -1907,6 +1910,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject uint32 m_CombatTimer; uint32 m_lastManaUse; // msecs + Spell* m_currentSpells[CURRENT_MAX_SPELL]; + UnitVisibility m_Visibility; Diminishing m_Diminishing; -- cgit v1.2.3