[10526] Implement server side global cooldown check.

Signed-off-by: VladimirMangos <vladimir@getmangos.com>

Also pet/controlled unit global cooldown code replaced by new placed in charmInfo structure.

Thanks to nos4r2zod for testing and gcd range check implement.
This commit is contained in:
darkstalker 2010-09-24 04:46:50 +04:00 committed by VladimirMangos
parent cb03e5a376
commit 3a8ad26a5e
12 changed files with 142 additions and 26 deletions

View file

@ -65,6 +65,9 @@ float baseMoveSpeed[MAX_MOVE_TYPE] =
3.14f // MOVE_PITCH_RATE
};
////////////////////////////////////////////////////////////
// Methods of class MovementInfo
void MovementInfo::Read(ByteBuffer &data)
{
data >> moveFlags;
@ -155,6 +158,28 @@ void MovementInfo::Write(ByteBuffer &data) const
}
}
////////////////////////////////////////////////////////////
// Methods of class GlobalCooldownMgr
bool GlobalCooldownMgr::HasGlobalCooldown(SpellEntry const* spellInfo) const
{
GlobalCooldownList::const_iterator itr = m_GlobalCooldowns.find(spellInfo->StartRecoveryCategory);
return itr != m_GlobalCooldowns.end() && itr->second.duration && getMSTimeDiff(itr->second.cast_time, getMSTime()) < itr->second.duration;
}
void GlobalCooldownMgr::AddGlobalCooldown(SpellEntry const* spellInfo, uint32 gcd)
{
m_GlobalCooldowns[spellInfo->StartRecoveryCategory] = GlobalCooldown(gcd, getMSTime());
}
void GlobalCooldownMgr::CancelGlobalCooldown(SpellEntry const* spellInfo)
{
m_GlobalCooldowns[spellInfo->StartRecoveryCategory].duration = 0;
}
////////////////////////////////////////////////////////////
// Methods of class Unit
Unit::Unit()
: WorldObject(), i_motionMaster(this), m_ThreatManager(this), m_HostileRefManager(this)
{