Skip to content

Commit

Permalink
[8084] Correctly show spell icon disabled state at relogin for spells…
Browse files Browse the repository at this point in the history
… with cooldown delayed until expire.
  • Loading branch information
VladimirMangos committed Jun 27, 2009
1 parent 2398f42 commit 01c6a9c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
27 changes: 15 additions & 12 deletions src/game/Player.cpp
Expand Up @@ -2535,7 +2535,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
void Player::SendInitialSpells()
{
time_t curTime = time(NULL);
time_t infTime = curTime + MONTH/2;
time_t infTime = curTime + infinityCooldownDelayCheck;

uint16 spellCount = 0;

Expand Down Expand Up @@ -2569,18 +2569,21 @@ void Player::SendInitialSpells()
if(!sEntry)
continue;

// not send infinity cooldown
if(itr->second.end > infTime)
continue;

data << uint32(itr->first);

time_t cooldown = 0;
if(itr->second.end > curTime)
cooldown = (itr->second.end-curTime)*IN_MILISECONDS;

data << uint16(itr->second.itemid); // cast item id
data << uint16(sEntry->Category); // spell category

// send infinity cooldown in special format
if(itr->second.end >= infTime)
{
data << uint32(1); // cooldown
data << uint32(0x80000000); // category cooldown
continue;
}

time_t cooldown = itr->second.end > curTime ? (itr->second.end-curTime)*IN_MILISECONDS : 0;

if(sEntry->Category) // may be wrong, but anyway better than nothing...
{
data << uint32(0); // cooldown
Expand Down Expand Up @@ -3347,7 +3350,7 @@ void Player::_SaveSpellCooldowns()
CharacterDatabase.PExecute("DELETE FROM character_spell_cooldown WHERE guid = '%u'", GetGUIDLow());

time_t curTime = time(NULL);
time_t infTime = curTime + MONTH/2;
time_t infTime = curTime + infinityCooldownDelayCheck;

// remove outdated and save active
for(SpellCooldowns::iterator itr = m_spellCooldowns.begin();itr != m_spellCooldowns.end();)
Expand Down Expand Up @@ -17384,8 +17387,8 @@ void Player::AddSpellAndCategoryCooldowns(SpellEntry const* spellInfo, uint32 it
{
// use +MONTH as infinity mark for spell cooldown (will checked as MONTH/2 at save ans skipped)
// but not allow ignore until reset or re-login
catrecTime = catrec > 0 ? curTime+MONTH : 0;
recTime = rec > 0 ? curTime+MONTH : catrecTime;
catrecTime = catrec > 0 ? curTime+infinityCooldownDelay : 0;
recTime = rec > 0 ? curTime+infinityCooldownDelay : catrecTime;
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions src/game/Player.h
Expand Up @@ -1462,6 +1462,8 @@ class MANGOS_DLL_SPEC Player : public Unit
template <class T> T ApplySpellMod(uint32 spellId, SpellModOp op, T &basevalue, Spell const* spell = NULL);
void RemoveSpellMods(Spell const* spell);

static uint32 const infinityCooldownDelay = MONTH; // used for set "infinity cooldowns" for spells and check
static uint32 const infinityCooldownDelayCheck = MONTH/2;
bool HasSpellCooldown(uint32 spell_id) const
{
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "8083"
#define REVISION_NR "8084"
#endif // __REVISION_NR_H__

0 comments on commit 01c6a9c

Please sign in to comment.