TrinityCore
Loading...
Searching...
No Matches
SpellHistory Class Reference

#include <SpellHistory.h>

Classes

struct  CooldownEntry
 
struct  PersistenceHelper
 
struct  PersistenceHelper< Pet >
 
struct  PersistenceHelper< Player >
 

Public Types

typedef std::chrono::system_clock Clock
 
typedef std::unordered_map< uint32, CooldownEntry > CooldownStorageType
 
typedef std::unordered_map< uint32, CooldownEntry * > CategoryCooldownStorageType
 
typedef std::unordered_map< uint32, Clock::time_point > GlobalCooldownStorageType
 

Public Member Functions

 SpellHistory (Unit *owner)
 
template<class OwnerType >
void LoadFromDB (PreparedQueryResult cooldownsResult)
 
template<class OwnerType >
void SaveToDB (CharacterDatabaseTransaction trans)
 
void Update ()
 
void HandleCooldowns (SpellInfo const *spellInfo, Item const *item, Spell *spell=nullptr)
 
void HandleCooldowns (SpellInfo const *spellInfo, uint32 itemID, Spell *spell=nullptr)
 
bool IsReady (SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
 
template<class OwnerType >
void WritePacket (WorldPacket &packet) const
 
void WritePacket (WorldPackets::Spells::InitialSpells *initialSpells) const
 
void StartCooldown (SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool onHold=false)
 
void SendCooldownEvent (SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool startCooldown=true)
 
template<class Type , class Period >
void AddCooldown (uint32 spellId, uint32 itemId, std::chrono::duration< Type, Period > cooldownDuration)
 
void AddCooldown (uint32 spellId, uint32 itemId, Clock::time_point cooldownEnd, uint32 categoryId, Clock::time_point categoryEnd, bool onHold=false)
 
void ModifyCooldown (uint32 spellId, int32 cooldownModMs)
 
void ResetCooldown (uint32 spellId, bool update=false)
 
void ResetCooldown (CooldownStorageType::iterator &itr, bool update=false)
 
template<typename Predicate >
void ResetCooldowns (Predicate predicate, bool update=false)
 
void ResetAllCooldowns ()
 
bool HasCooldown (SpellInfo const *spellInfo, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
 
bool HasCooldown (uint32 spellId, uint32 itemId=0, bool ignoreCategoryCooldown=false) const
 
bool HasCooldownOnHold (uint32 spellId) const
 
uint32 GetRemainingCooldown (SpellInfo const *spellInfo) const
 
void LockSpellSchool (SpellSchoolMask schoolMask, uint32 lockoutTime)
 
bool IsSchoolLocked (SpellSchoolMask schoolMask) const
 
bool HasGlobalCooldown (SpellInfo const *spellInfo) const
 
void AddGlobalCooldown (SpellInfo const *spellInfo, uint32 duration)
 
void CancelGlobalCooldown (SpellInfo const *spellInfo)
 
void BuildCooldownPacket (WorldPacket &data, uint8 flags, uint32 spellId, uint32 cooldown) const
 
CooldownStorageType::size_type GetCooldownsSizeForPacket () const
 
void SaveCooldownStateBeforeDuel ()
 
void RestoreCooldownStateAfterDuel ()
 
template<>
void WritePacket (WorldPacket &packet) const
 

Static Public Member Functions

static void GetCooldownDurations (SpellInfo const *spellInfo, uint32 itemId, int32 *cooldown, uint32 *categoryId, int32 *categoryCooldown)
 

Static Public Attributes

static Clock::duration const InfinityCooldownDelay = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH))
 
static Clock::duration const InfinityCooldownDelayCheck = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH / 2))
 

Private Types

typedef std::unordered_map< uint32, uint32 > PacketCooldowns
 

Private Member Functions

Player * GetPlayerOwner () const
 
void SendClearCooldowns (std::vector< int32 > const &cooldowns) const
 
CooldownStorageType::iterator EraseCooldown (CooldownStorageType::iterator itr)
 
void BuildCooldownPacket (WorldPacket &data, uint8 flags, PacketCooldowns const &cooldowns) const
 

Private Attributes

Unit * _owner
 
CooldownStorageType _spellCooldowns
 
CooldownStorageType _spellCooldownsBeforeDuel
 
CategoryCooldownStorageType _categoryCooldowns
 
Clock::time_point _schoolLockouts [MAX_SPELL_SCHOOL]
 
GlobalCooldownStorageType _globalCooldowns
 

Detailed Description

Definition at line 48 of file SpellHistory.h.

Member Typedef Documentation

◆ CategoryCooldownStorageType

Definition at line 64 of file SpellHistory.h.

◆ Clock

typedef std::chrono::system_clock SpellHistory::Clock

Definition at line 51 of file SpellHistory.h.

◆ CooldownStorageType

Definition at line 63 of file SpellHistory.h.

◆ GlobalCooldownStorageType

typedef std::unordered_map<uint32 , Clock::time_point> SpellHistory::GlobalCooldownStorageType

Definition at line 65 of file SpellHistory.h.

◆ PacketCooldowns

typedef std::unordered_map<uint32, uint32> SpellHistory::PacketCooldowns
private

Definition at line 154 of file SpellHistory.h.

Constructor & Destructor Documentation

◆ SpellHistory()

SpellHistory::SpellHistory ( Unit *  owner)
inlineexplicit

Definition at line 67 of file SpellHistory.h.

Member Function Documentation

◆ AddCooldown() [1/2]

void SpellHistory::AddCooldown ( uint32  spellId,
uint32  itemId,
Clock::time_point  cooldownEnd,
uint32  categoryId,
Clock::time_point  categoryEnd,
bool  onHold = false 
)

◆ AddCooldown() [2/2]

◆ AddGlobalCooldown()

void SpellHistory::AddGlobalCooldown ( SpellInfo const *  spellInfo,
uint32  duration 
)

◆ BuildCooldownPacket() [1/2]

void SpellHistory::BuildCooldownPacket ( WorldPacket &  data,
uint8  flags,
PacketCooldowns const &  cooldowns 
) const
private

◆ BuildCooldownPacket() [2/2]

◆ CancelGlobalCooldown()

void SpellHistory::CancelGlobalCooldown ( SpellInfo const *  spellInfo)

Definition at line 591 of file SpellHistory.cpp.

References _globalCooldowns, and SpellInfo::StartRecoveryCategory.

Referenced by Spell::CancelGlobalCooldown().

◆ EraseCooldown()

CooldownStorageType::iterator SpellHistory::EraseCooldown ( CooldownStorageType::iterator  itr)
inlineprivate

Definition at line 148 of file SpellHistory.h.

Referenced by ModifyCooldown(), ResetCooldown(), and Update().

◆ GetCooldownDurations()

void SpellHistory::GetCooldownDurations ( SpellInfo const *  spellInfo,
uint32  itemId,
int32 *  cooldown,
uint32 *  categoryId,
int32 *  categoryCooldown 
)
static

◆ GetCooldownsSizeForPacket()

CooldownStorageType::size_type SpellHistory::GetCooldownsSizeForPacket ( ) const
inline

Definition at line 141 of file SpellHistory.h.

Referenced by Player::VehicleSpellInitialize().

◆ GetPlayerOwner()

◆ GetRemainingCooldown()

◆ HandleCooldowns() [1/2]

void SpellHistory::HandleCooldowns ( SpellInfo const *  spellInfo,
Item const *  item,
Spell *  spell = nullptr 
)

Definition at line 162 of file SpellHistory.cpp.

References Object::GetEntry(), and HandleCooldowns().

Referenced by HandleCooldowns(), and Spell::SendSpellCooldown().

◆ HandleCooldowns() [2/2]

void SpellHistory::HandleCooldowns ( SpellInfo const *  spellInfo,
uint32  itemID,
Spell *  spell = nullptr 
)

◆ HasCooldown() [1/2]

◆ HasCooldown() [2/2]

bool SpellHistory::HasCooldown ( uint32  spellId,
uint32  itemId = 0,
bool  ignoreCategoryCooldown = false 
) const

Definition at line 477 of file SpellHistory.cpp.

References HasCooldown(), and sSpellMgr.

◆ HasCooldownOnHold()

bool SpellHistory::HasCooldownOnHold ( uint32  spellId) const

Definition at line 482 of file SpellHistory.cpp.

References _spellCooldowns.

Referenced by Spell::CheckCast().

◆ HasGlobalCooldown()

bool SpellHistory::HasGlobalCooldown ( SpellInfo const *  spellInfo) const

◆ IsReady()

bool SpellHistory::IsReady ( SpellInfo const *  spellInfo,
uint32  itemId = 0,
bool  ignoreCategoryCooldown = false 
) const

◆ IsSchoolLocked()

bool SpellHistory::IsSchoolLocked ( SpellSchoolMask  schoolMask) const

Definition at line 569 of file SpellHistory.cpp.

References _schoolLockouts, GameTime::GetSystemTime(), and MAX_SPELL_SCHOOL.

Referenced by IsReady().

◆ LoadFromDB()

template<class OwnerType >
template void SpellHistory::LoadFromDB< Pet > ( PreparedQueryResult  cooldownsResult)

◆ LockSpellSchool()

◆ ModifyCooldown()

void SpellHistory::ModifyCooldown ( uint32  spellId,
int32  cooldownModMs 
)

◆ ResetAllCooldowns()

◆ ResetCooldown() [1/2]

void SpellHistory::ResetCooldown ( CooldownStorageType::iterator &  itr,
bool  update = false 
)

◆ ResetCooldown() [2/2]

◆ ResetCooldowns()

◆ RestoreCooldownStateAfterDuel()

◆ SaveCooldownStateBeforeDuel()

void SpellHistory::SaveCooldownStateBeforeDuel ( )

Definition at line 678 of file SpellHistory.cpp.

References _spellCooldowns, and _spellCooldownsBeforeDuel.

Referenced by DuelResetScript::OnDuelStart().

◆ SaveToDB()

template<class OwnerType >
template void SpellHistory::SaveToDB< Pet > ( CharacterDatabaseTransaction  trans)

Definition at line 120 of file SpellHistory.cpp.

References _owner, _spellCooldowns, and CharacterDatabase.

Referenced by Pet::SavePetToDB(), and Player::SaveToDB().

◆ SendClearCooldowns()

void SpellHistory::SendClearCooldowns ( std::vector< int32 > const &  cooldowns) const
private

Definition at line 601 of file SpellHistory.cpp.

References _owner, Object::GetGUID(), GetPlayerOwner(), and SMSG_CLEAR_COOLDOWN.

Referenced by ResetAllCooldowns().

◆ SendCooldownEvent()

void SpellHistory::SendCooldownEvent ( SpellInfo const *  spellInfo,
uint32  itemId = 0,
Spell *  spell = nullptr,
bool  startCooldown = true 
)

◆ StartCooldown()

◆ Update()

void SpellHistory::Update ( )

◆ WritePacket() [1/3]

template<>
void SpellHistory::WritePacket ( WorldPacket &  packet) const

Definition at line 204 of file SpellHistory.cpp.

References _spellCooldowns, and GameTime::GetSystemTime().

◆ WritePacket() [2/3]

template<class OwnerType >
void SpellHistory::WritePacket ( WorldPacket &  packet) const

◆ WritePacket() [3/3]

Member Data Documentation

◆ _categoryCooldowns

CategoryCooldownStorageType SpellHistory::_categoryCooldowns
private

◆ _globalCooldowns

GlobalCooldownStorageType SpellHistory::_globalCooldowns
private

Definition at line 162 of file SpellHistory.h.

Referenced by AddGlobalCooldown(), CancelGlobalCooldown(), and HasGlobalCooldown().

◆ _owner

◆ _schoolLockouts

Clock::time_point SpellHistory::_schoolLockouts[MAX_SPELL_SCHOOL]
private

Definition at line 161 of file SpellHistory.h.

Referenced by IsSchoolLocked(), and LockSpellSchool().

◆ _spellCooldowns

◆ _spellCooldownsBeforeDuel

CooldownStorageType SpellHistory::_spellCooldownsBeforeDuel
private

Definition at line 159 of file SpellHistory.h.

Referenced by RestoreCooldownStateAfterDuel(), and SaveCooldownStateBeforeDuel().

◆ InfinityCooldownDelay

SpellHistory::Clock::duration const SpellHistory::InfinityCooldownDelay = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH))
static

Definition at line 85 of file SpellHistory.h.

Referenced by StartCooldown().

◆ InfinityCooldownDelayCheck

SpellHistory::Clock::duration const SpellHistory::InfinityCooldownDelayCheck = std::chrono::duration_cast<SpellHistory::Clock::duration>(std::chrono::seconds(MONTH / 2))
static

Definition at line 86 of file SpellHistory.h.


The documentation for this class was generated from the following files: