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, CooldownEntryCooldownStorageType
 
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
 
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, uint32PacketCooldowns
 

Private Member Functions

PlayerGetPlayerOwner () 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 153 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 
)

Definition at line 383 of file SpellHistory.cpp.

◆ AddCooldown() [2/2]

template<class Type , class Period >
void SpellHistory::AddCooldown ( uint32  spellId,
uint32  itemId,
std::chrono::duration< Type, Period >  cooldownDuration 
)
inline

Definition at line 92 of file SpellHistory.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddGlobalCooldown()

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

Definition at line 579 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BuildCooldownPacket() [1/2]

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

Definition at line 617 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ BuildCooldownPacket() [2/2]

void SpellHistory::BuildCooldownPacket ( WorldPacket data,
uint8  flags,
uint32  spellId,
uint32  cooldown 
) const

Definition at line 608 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CancelGlobalCooldown()

void SpellHistory::CancelGlobalCooldown ( SpellInfo const *  spellInfo)

Definition at line 584 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ EraseCooldown()

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

Definition at line 147 of file SpellHistory.h.

+ Here is the caller graph for this function:

◆ GetCooldownDurations()

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

Definition at line 629 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCooldownsSizeForPacket()

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

Definition at line 140 of file SpellHistory.h.

+ Here is the caller graph for this function:

◆ GetPlayerOwner()

Player * SpellHistory::GetPlayerOwner ( ) const
private

Definition at line 589 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetRemainingCooldown()

uint32 SpellHistory::GetRemainingCooldown ( SpellInfo const *  spellInfo) const

Definition at line 482 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleCooldowns() [1/2]

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

Definition at line 162 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandleCooldowns() [2/2]

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

Definition at line 167 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ HasCooldown() [1/2]

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

Definition at line 461 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HasCooldown() [2/2]

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

Definition at line 477 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ HasGlobalCooldown()

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

Definition at line 573 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsReady()

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

Definition at line 191 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsSchoolLocked()

bool SpellHistory::IsSchoolLocked ( SpellSchoolMask  schoolMask) const

Definition at line 562 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadFromDB()

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

Definition at line 98 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ LockSpellSchool()

void SpellHistory::LockSpellSchool ( SpellSchoolMask  schoolMask,
uint32  lockoutTime 
)

Definition at line 505 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ModifyCooldown()

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

Definition at line 397 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ ResetAllCooldowns()

void SpellHistory::ResetAllCooldowns ( )

Definition at line 445 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResetCooldown() [1/2]

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

Definition at line 429 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ ResetCooldown() [2/2]

void SpellHistory::ResetCooldown ( uint32  spellId,
bool  update = false 
)

Definition at line 420 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResetCooldowns()

template<typename Predicate >
void SpellHistory::ResetCooldowns ( Predicate  predicate,
bool  update = false 
)
inline

Definition at line 103 of file SpellHistory.h.

+ Here is the caller graph for this function:

◆ RestoreCooldownStateAfterDuel()

void SpellHistory::RestoreCooldownStateAfterDuel ( )

Definition at line 676 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SaveCooldownStateBeforeDuel()

void SpellHistory::SaveCooldownStateBeforeDuel ( )

Definition at line 671 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ SaveToDB()

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

Definition at line 120 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ SendClearCooldowns()

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

Definition at line 594 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SendCooldownEvent()

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

Definition at line 352 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StartCooldown()

void SpellHistory::StartCooldown ( SpellInfo const *  spellInfo,
uint32  itemId,
Spell spell = nullptr,
bool  onHold = false 
)

Definition at line 271 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Update()

void SpellHistory::Update ( )

Definition at line 142 of file SpellHistory.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ WritePacket() [1/3]

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

Definition at line 204 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ WritePacket() [2/3]

template<class OwnerType >
void SpellHistory::WritePacket ( WorldPacket packet) const
+ Here is the caller graph for this function:

◆ WritePacket() [3/3]

void SpellHistory::WritePacket ( WorldPackets::Spells::InitialSpells initialSpells) const

Definition at line 240 of file SpellHistory.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ _categoryCooldowns

CategoryCooldownStorageType SpellHistory::_categoryCooldowns
private

Definition at line 159 of file SpellHistory.h.

◆ _globalCooldowns

GlobalCooldownStorageType SpellHistory::_globalCooldowns
private

Definition at line 161 of file SpellHistory.h.

◆ _owner

Unit* SpellHistory::_owner
private

Definition at line 156 of file SpellHistory.h.

◆ _schoolLockouts

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

Definition at line 160 of file SpellHistory.h.

◆ _spellCooldowns

CooldownStorageType SpellHistory::_spellCooldowns
private

Definition at line 157 of file SpellHistory.h.

◆ _spellCooldownsBeforeDuel

CooldownStorageType SpellHistory::_spellCooldownsBeforeDuel
private

Definition at line 158 of file SpellHistory.h.

◆ 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.

◆ 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: