Core/Spell Mechanics: introduce global cooldown manager for server-side checks for GCD (ported from mangos)

This commit is contained in:
darkstalker
2011-02-22 17:02:47 +06:00
committed by Azazel
parent 401ec2180f
commit 1646f9d91c
9 changed files with 130 additions and 18 deletions
+28
View File
@@ -937,6 +937,30 @@ enum CurrentSpellTypes
#define CURRENT_FIRST_NON_MELEE_SPELL 1
#define CURRENT_MAX_SPELL 4
struct GlobalCooldown
{
explicit GlobalCooldown(uint32 _dur = 0, uint32 _time = 0) : duration(_dur), cast_time(_time) {}
uint32 duration;
uint32 cast_time;
};
typedef UNORDERED_MAP<uint32 /*category*/, GlobalCooldown> GlobalCooldownList;
class GlobalCooldownMgr // Shared by Player and CharmInfo
{
public:
GlobalCooldownMgr() {}
public:
bool HasGlobalCooldown(SpellEntry const* spellInfo) const;
void AddGlobalCooldown(SpellEntry const* spellInfo, uint32 gcd);
void CancelGlobalCooldown(SpellEntry const* spellInfo);
private:
GlobalCooldownList m_GlobalCooldowns;
};
enum ActiveStates
{
ACT_PASSIVE = 0x01, // 0x01 - passive
@@ -1057,6 +1081,8 @@ struct CharmInfo
CharmSpellEntry* GetCharmSpell(uint8 index) { return &(m_charmspells[index]); }
GlobalCooldownMgr& GetGlobalCooldownMgr() { return m_GlobalCooldownMgr; }
void SetIsCommandAttack(bool val);
bool IsCommandAttack();
void SetIsAtStay(bool val);
@@ -1088,6 +1114,8 @@ struct CharmInfo
float m_stayX;
float m_stayY;
float m_stayZ;
GlobalCooldownMgr m_GlobalCooldownMgr;
};
// for clearing special attacks