[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
This commit is contained in:
megamage
2009-08-19 16:52:51 -05:00
parent 6181620520
commit 012d6fa865
11 changed files with 87 additions and 86 deletions
+14 -9
View File
@@ -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;