TrinityCore
SpellHistory Class Reference

#include <SpellHistory.h>

Classes

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

Public Types

using Clock = std::chrono::system_clock
 
using Duration = Milliseconds
 
using TimePoint = std::chrono::time_point< Clock, Duration >
 
using ChargeEntryCollection = std::deque< ChargeEntry >
 
using CooldownStorageType = std::unordered_map< uint32, CooldownEntry >
 
using CategoryCooldownStorageType = std::unordered_map< uint32, CooldownEntry * >
 
using ChargeStorageType = std::unordered_map< uint32, ChargeEntryCollection >
 
using GlobalCooldownStorageType = std::unordered_map< uint32, TimePoint >
 

Public Member Functions

 SpellHistory (Unit *owner)
 
 ~SpellHistory ()
 
 SpellHistory (SpellHistory const &)=delete
 
 SpellHistory (SpellHistory &&)=delete
 
SpellHistoryoperator= (SpellHistory const &)=delete
 
SpellHistoryoperator= (SpellHistory &&)=delete
 
template<class OwnerType >
void LoadFromDB (PreparedQueryResult cooldownsResult, PreparedQueryResult chargesResult)
 
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) const
 
template<class PacketType >
void WritePacket (PacketType *packet) const
 
void StartCooldown (SpellInfo const *spellInfo, uint32 itemId, Spell *spell=nullptr, bool onHold=false, Optional< Duration > forcedCooldown={})
 
void SendCooldownEvent (SpellInfo const *spellInfo, uint32 itemId=0, Spell *spell=nullptr, bool startCooldown=true)
 
void AddCooldown (uint32 spellId, uint32 itemId, Duration cooldownDuration)
 
void AddCooldown (uint32 spellId, uint32 itemId, TimePoint cooldownEnd, uint32 categoryId, TimePoint categoryEnd, bool onHold=false)
 
void ModifyCooldown (uint32 spellId, Duration cooldownMod, bool withoutCategoryCooldown=false)
 
void ModifyCooldown (SpellInfo const *spellInfo, Duration cooldownMod, bool withoutCategoryCooldown=false)
 
template<typename Predicate >
void ModifyCoooldowns (Predicate &&predicate, Duration cooldownMod, bool withoutCategoryCooldown=false)
 
void ResetCooldown (uint32 spellId, bool update=false)
 
template<typename Predicate >
void ResetCooldowns (Predicate predicate, bool update=false)
 
void ResetAllCooldowns ()
 
bool HasCooldown (SpellInfo const *spellInfo, uint32 itemId=0) const
 
bool HasCooldown (uint32 spellId, uint32 itemId=0) const
 
Duration GetRemainingCooldown (SpellInfo const *spellInfo) const
 
Duration GetRemainingCategoryCooldown (uint32 categoryId) const
 
Duration GetRemainingCategoryCooldown (SpellInfo const *spellInfo) const
 
void LockSpellSchool (SpellSchoolMask schoolMask, Duration lockoutTime)
 
bool IsSchoolLocked (SpellSchoolMask schoolMask) const
 
bool ConsumeCharge (uint32 chargeCategoryId)
 
void ModifyChargeRecoveryTime (uint32 chargeCategoryId, Duration cooldownMod)
 
void RestoreCharge (uint32 chargeCategoryId)
 
void ResetCharges (uint32 chargeCategoryId)
 
void ResetAllCharges ()
 
bool HasCharge (uint32 chargeCategoryId) const
 
int32 GetMaxCharges (uint32 chargeCategoryId) const
 
int32 GetChargeRecoveryTime (uint32 chargeCategoryId) const
 
bool HasGlobalCooldown (SpellInfo const *spellInfo) const
 
void AddGlobalCooldown (SpellInfo const *spellInfo, Duration duration)
 
void CancelGlobalCooldown (SpellInfo const *spellInfo)
 
Duration GetRemainingGlobalCooldown (SpellInfo const *spellInfo) const
 
bool IsPaused () const
 
void PauseCooldowns ()
 
void ResumeCooldowns ()
 
void SaveCooldownStateBeforeDuel ()
 
void RestoreCooldownStateAfterDuel ()
 
template<>
void WritePacket (WorldPackets::Spells::SendSpellHistory *sendSpellHistory) const
 
template<>
void WritePacket (WorldPackets::Spells::SendSpellCharges *sendSpellCharges) const
 
template<>
void WritePacket (WorldPackets::Pet::PetSpells *petSpells) const
 

Static Public Attributes

static Duration const InfinityCooldownDelay = Seconds(MONTH)
 

Private Member Functions

PlayerGetPlayerOwner () const
 
void ModifySpellCooldown (uint32 spellId, Duration cooldownMod, bool withoutCategoryCooldown)
 
void ModifySpellCooldown (CooldownStorageType::iterator &itr, Duration cooldownMod, bool withoutCategoryCooldown)
 
void ResetCooldown (CooldownStorageType::iterator &itr, bool update=false)
 
void SendClearCooldowns (std::vector< int32 > const &cooldowns) const
 
CooldownStorageType::iterator EraseCooldown (CooldownStorageType::iterator itr)
 
void SendSetSpellCharges (uint32 chargeCategoryId, ChargeEntryCollection const &chargeCollection)
 

Static Private Member Functions

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

Private Attributes

Unit_owner
 
CooldownStorageType _spellCooldowns
 
CooldownStorageType _spellCooldownsBeforeDuel
 
CategoryCooldownStorageType _categoryCooldowns
 
TimePoint _schoolLockouts [MAX_SPELL_SCHOOL]
 
ChargeStorageType _categoryCharges
 
GlobalCooldownStorageType _globalCooldowns
 
Optional< TimePoint_pauseTime
 

Detailed Description

Definition at line 46 of file SpellHistory.h.

Member Typedef Documentation

◆ CategoryCooldownStorageType

Definition at line 75 of file SpellHistory.h.

◆ ChargeEntryCollection

Definition at line 73 of file SpellHistory.h.

◆ ChargeStorageType

Definition at line 76 of file SpellHistory.h.

◆ Clock

using SpellHistory::Clock = std::chrono::system_clock

Definition at line 49 of file SpellHistory.h.

◆ CooldownStorageType

Definition at line 74 of file SpellHistory.h.

◆ Duration

Definition at line 50 of file SpellHistory.h.

◆ GlobalCooldownStorageType

Definition at line 77 of file SpellHistory.h.

◆ TimePoint

using SpellHistory::TimePoint = std::chrono::time_point<Clock, Duration>

Definition at line 51 of file SpellHistory.h.

Constructor & Destructor Documentation

◆ SpellHistory() [1/3]

SpellHistory::SpellHistory ( Unit owner)
explicit

Definition at line 140 of file SpellHistory.cpp.

◆ ~SpellHistory()

SpellHistory::~SpellHistory ( )
default

◆ SpellHistory() [2/3]

SpellHistory::SpellHistory ( SpellHistory const &  )
delete

◆ SpellHistory() [3/3]

SpellHistory::SpellHistory ( SpellHistory &&  )
delete

Member Function Documentation

◆ AddCooldown() [1/2]

void SpellHistory::AddCooldown ( uint32  spellId,
uint32  itemId,
Duration  cooldownDuration 
)
inline

Definition at line 108 of file SpellHistory.h.

+ Here is the caller graph for this function:

◆ AddCooldown() [2/2]

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

Definition at line 551 of file SpellHistory.cpp.

◆ AddGlobalCooldown()

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

Definition at line 941 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ CancelGlobalCooldown()

void SpellHistory::CancelGlobalCooldown ( SpellInfo const *  spellInfo)

Definition at line 946 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ ConsumeCharge()

bool SpellHistory::ConsumeCharge ( uint32  chargeCategoryId)

Definition at line 803 of file SpellHistory.cpp.

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

◆ EraseCooldown()

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

Definition at line 190 of file SpellHistory.h.

+ Here is the caller graph for this function:

◆ GetChargeRecoveryTime()

int32 SpellHistory::GetChargeRecoveryTime ( uint32  chargeCategoryId) const

Definition at line 914 of file SpellHistory.cpp.

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

◆ GetCooldownDurations()

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

Definition at line 1021 of file SpellHistory.cpp.

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

◆ GetMaxCharges()

int32 SpellHistory::GetMaxCharges ( uint32  chargeCategoryId) const

Definition at line 903 of file SpellHistory.cpp.

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

◆ GetPlayerOwner()

Player * SpellHistory::GetPlayerOwner ( ) const
private

Definition at line 991 of file SpellHistory.cpp.

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

◆ GetRemainingCategoryCooldown() [1/2]

SpellHistory::Duration SpellHistory::GetRemainingCategoryCooldown ( SpellInfo const *  spellInfo) const

Definition at line 731 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ GetRemainingCategoryCooldown() [2/2]

SpellHistory::Duration SpellHistory::GetRemainingCategoryCooldown ( uint32  categoryId) const

Definition at line 714 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ GetRemainingCooldown()

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

Definition at line 691 of file SpellHistory.cpp.

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

◆ GetRemainingGlobalCooldown()

SpellHistory::Duration SpellHistory::GetRemainingGlobalCooldown ( SpellInfo const *  spellInfo) const

Definition at line 951 of file SpellHistory.cpp.

+ 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 244 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 249 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ HasCharge()

bool SpellHistory::HasCharge ( uint32  chargeCategoryId) const

Definition at line 889 of file SpellHistory.cpp.

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

◆ HasCooldown() [1/2]

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

Definition at line 667 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 
) const

Definition at line 686 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ HasGlobalCooldown()

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

Definition at line 935 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ IsPaused()

bool SpellHistory::IsPaused ( ) const
inline

Definition at line 177 of file SpellHistory.h.

◆ IsReady()

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

Definition at line 276 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 792 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ LoadFromDB()

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

Definition at line 147 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ LockSpellSchool()

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

Definition at line 736 of file SpellHistory.cpp.

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

◆ ModifyChargeRecoveryTime()

void SpellHistory::ModifyChargeRecoveryTime ( uint32  chargeCategoryId,
Duration  cooldownMod 
)

Definition at line 825 of file SpellHistory.cpp.

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

◆ ModifyCooldown() [1/2]

void SpellHistory::ModifyCooldown ( SpellInfo const *  spellInfo,
Duration  cooldownMod,
bool  withoutCategoryCooldown = false 
)

Definition at line 614 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ ModifyCooldown() [2/2]

void SpellHistory::ModifyCooldown ( uint32  spellId,
Duration  cooldownMod,
bool  withoutCategoryCooldown = false 
)

Definition at line 608 of file SpellHistory.cpp.

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

◆ ModifyCoooldowns()

template<typename Predicate >
void SpellHistory::ModifyCoooldowns ( Predicate &&  predicate,
Duration  cooldownMod,
bool  withoutCategoryCooldown = false 
)
inline

Definition at line 118 of file SpellHistory.h.

+ Here is the caller graph for this function:

◆ ModifySpellCooldown() [1/2]

void SpellHistory::ModifySpellCooldown ( CooldownStorageType::iterator &  itr,
Duration  cooldownMod,
bool  withoutCategoryCooldown 
)
private

Definition at line 578 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ ModifySpellCooldown() [2/2]

void SpellHistory::ModifySpellCooldown ( uint32  spellId,
Duration  cooldownMod,
bool  withoutCategoryCooldown 
)
private

Definition at line 569 of file SpellHistory.cpp.

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

◆ operator=() [1/2]

SpellHistory & SpellHistory::operator= ( SpellHistory &&  )
delete

◆ operator=() [2/2]

SpellHistory & SpellHistory::operator= ( SpellHistory const &  )
delete

◆ PauseCooldowns()

void SpellHistory::PauseCooldowns ( )

Definition at line 967 of file SpellHistory.cpp.

◆ ResetAllCharges()

void SpellHistory::ResetAllCharges ( )

Definition at line 877 of file SpellHistory.cpp.

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

◆ ResetAllCooldowns()

void SpellHistory::ResetAllCooldowns ( )

Definition at line 651 of file SpellHistory.cpp.

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

◆ ResetCharges()

void SpellHistory::ResetCharges ( uint32  chargeCategoryId)

Definition at line 860 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 
)
private

Definition at line 634 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 625 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 131 of file SpellHistory.h.

+ Here is the caller graph for this function:

◆ RestoreCharge()

void SpellHistory::RestoreCharge ( uint32  chargeCategoryId)

Definition at line 849 of file SpellHistory.cpp.

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

◆ RestoreCooldownStateAfterDuel()

void SpellHistory::RestoreCooldownStateAfterDuel ( )

Definition at line 1067 of file SpellHistory.cpp.

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

◆ ResumeCooldowns()

void SpellHistory::ResumeCooldowns ( )

Definition at line 972 of file SpellHistory.cpp.

+ Here is the call graph for this function:

◆ SaveCooldownStateBeforeDuel()

void SpellHistory::SaveCooldownStateBeforeDuel ( )

Definition at line 1062 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 182 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 996 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 526 of file SpellHistory.cpp.

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

◆ SendSetSpellCharges()

void SpellHistory::SendSetSpellCharges ( uint32  chargeCategoryId,
ChargeEntryCollection const &  chargeCollection 
)
private

Definition at line 1007 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,
Optional< Duration forcedCooldown = {} 
)

Definition at line 403 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 220 of file SpellHistory.cpp.

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

◆ WritePacket() [1/4]

template<class PacketType >
void SpellHistory::WritePacket ( PacketType *  packet) const

Definition at line 292 of file SpellHistory.cpp.

+ Here is the caller graph for this function:

◆ WritePacket() [2/4]

template<>
void SpellHistory::WritePacket ( WorldPackets::Pet::PetSpells petSpells) const

Definition at line 356 of file SpellHistory.cpp.

◆ WritePacket() [3/4]

template<>
void SpellHistory::WritePacket ( WorldPackets::Spells::SendSpellCharges sendSpellCharges) const

Definition at line 333 of file SpellHistory.cpp.

◆ WritePacket() [4/4]

template<>
void SpellHistory::WritePacket ( WorldPackets::Spells::SendSpellHistory sendSpellHistory) const

Definition at line 298 of file SpellHistory.cpp.

Member Data Documentation

◆ _categoryCharges

ChargeStorageType SpellHistory::_categoryCharges
private

Definition at line 205 of file SpellHistory.h.

◆ _categoryCooldowns

CategoryCooldownStorageType SpellHistory::_categoryCooldowns
private

Definition at line 203 of file SpellHistory.h.

◆ _globalCooldowns

GlobalCooldownStorageType SpellHistory::_globalCooldowns
private

Definition at line 206 of file SpellHistory.h.

◆ _owner

Unit* SpellHistory::_owner
private

Definition at line 200 of file SpellHistory.h.

◆ _pauseTime

Optional<TimePoint> SpellHistory::_pauseTime
private

Definition at line 207 of file SpellHistory.h.

◆ _schoolLockouts

TimePoint SpellHistory::_schoolLockouts[MAX_SPELL_SCHOOL]
private

Definition at line 204 of file SpellHistory.h.

◆ _spellCooldowns

CooldownStorageType SpellHistory::_spellCooldowns
private

Definition at line 201 of file SpellHistory.h.

◆ _spellCooldownsBeforeDuel

CooldownStorageType SpellHistory::_spellCooldownsBeforeDuel
private

Definition at line 202 of file SpellHistory.h.

◆ InfinityCooldownDelay

SpellHistory::Duration const SpellHistory::InfinityCooldownDelay = Seconds(MONTH)
static

Definition at line 103 of file SpellHistory.h.


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