*Some optimization of aura update.
--HG-- branch : trunk
This commit is contained in:
+13
-9
@@ -345,7 +345,7 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
|
|||||||
|
|
||||||
Aura::Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, WorldObject *source, Unit *caster, Item* castItem) :
|
Aura::Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, WorldObject *source, Unit *caster, Item* castItem) :
|
||||||
m_caster_guid(0), m_castItemGuid(castItem?castItem->GetGUID():0), m_target(target),
|
m_caster_guid(0), m_castItemGuid(castItem?castItem->GetGUID():0), m_target(target),
|
||||||
m_timeCla(1000), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
|
m_timeCla(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
|
||||||
m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),m_auraStateMask(0), m_updated(false), m_isRemoved(false)
|
m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),m_auraStateMask(0), m_updated(false), m_isRemoved(false)
|
||||||
{
|
{
|
||||||
assert(target);
|
assert(target);
|
||||||
@@ -356,6 +356,9 @@ m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),m_aura
|
|||||||
|
|
||||||
m_spellProto = spellproto;
|
m_spellProto = spellproto;
|
||||||
|
|
||||||
|
if(m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel)
|
||||||
|
m_timeCla = 1000;
|
||||||
|
|
||||||
m_isPassive = IsPassiveSpell(GetId());
|
m_isPassive = IsPassiveSpell(GetId());
|
||||||
|
|
||||||
m_auraStateMask = 0;
|
m_auraStateMask = 0;
|
||||||
@@ -627,15 +630,15 @@ void Aura::Update(uint32 diff)
|
|||||||
m_duration = 0;
|
m_duration = 0;
|
||||||
|
|
||||||
// all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
|
// all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0
|
||||||
if(m_timeCla > 0)
|
if(m_timeCla)
|
||||||
m_timeCla -= diff;
|
|
||||||
if(m_timeCla <= 0)
|
|
||||||
{
|
{
|
||||||
if(Unit* caster = GetCaster())
|
if(m_timeCla > diff)
|
||||||
|
m_timeCla -= diff;
|
||||||
|
else if(Unit* caster = GetCaster())
|
||||||
{
|
{
|
||||||
if(int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel())
|
if(int32 manaPerSecond = m_spellProto->manaPerSecond + m_spellProto->manaPerSecondPerLevel * caster->getLevel())
|
||||||
{
|
{
|
||||||
m_timeCla = 1000;
|
m_timeCla += 1000 - diff;
|
||||||
|
|
||||||
Powers powertype = Powers(m_spellProto->powerType);
|
Powers powertype = Powers(m_spellProto->powerType);
|
||||||
if(powertype == POWER_HEALTH)
|
if(powertype == POWER_HEALTH)
|
||||||
@@ -672,13 +675,14 @@ void AuraEffect::Update(uint32 diff)
|
|||||||
{
|
{
|
||||||
if (m_isPeriodic && (GetParentAura()->GetAuraDuration() >=0 || GetParentAura()->IsPassive() || GetParentAura()->IsPermanent()))
|
if (m_isPeriodic && (GetParentAura()->GetAuraDuration() >=0 || GetParentAura()->IsPassive() || GetParentAura()->IsPermanent()))
|
||||||
{
|
{
|
||||||
m_periodicTimer -= diff;
|
if(m_periodicTimer > diff)
|
||||||
if(m_periodicTimer <= 0) // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
|
m_periodicTimer -= diff;
|
||||||
|
else // tick also at m_periodicTimer==0 to prevent lost last tick in case max m_duration == (max m_periodicTimer)*N
|
||||||
{
|
{
|
||||||
++m_tickNumber;
|
++m_tickNumber;
|
||||||
|
|
||||||
// update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
|
// update before applying (aura can be removed in TriggerSpell or PeriodicTick calls)
|
||||||
m_periodicTimer += m_amplitude;
|
m_periodicTimer += m_amplitude - diff;
|
||||||
|
|
||||||
if(!m_target->hasUnitState(UNIT_STAT_ISOLATED))
|
if(!m_target->hasUnitState(UNIT_STAT_ISOLATED))
|
||||||
PeriodicTick();
|
PeriodicTick();
|
||||||
|
|||||||
+12
-15
@@ -3305,12 +3305,11 @@ uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target)
|
|||||||
|
|
||||||
void Unit::_DeleteAuras()
|
void Unit::_DeleteAuras()
|
||||||
{
|
{
|
||||||
for (AuraList::iterator i = m_removedAuras.begin(); i != m_removedAuras.end();i = m_removedAuras.begin())
|
while(!m_removedAuras.empty())
|
||||||
{
|
{
|
||||||
Aura * Aur = *i;
|
delete m_removedAuras.front();
|
||||||
sLog.outDebug("Aura %d is deleted from unit %d", Aur->GetId(), GetGUIDLow());
|
|
||||||
m_removedAuras.pop_front();
|
m_removedAuras.pop_front();
|
||||||
delete (Aur);
|
// sLog.outDebug("Aura %d is deleted from unit %d", Aur->GetId(), GetGUIDLow());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3320,7 +3319,7 @@ void Unit::_UpdateSpells( uint32 time )
|
|||||||
_UpdateAutoRepeatSpell();
|
_UpdateAutoRepeatSpell();
|
||||||
|
|
||||||
// remove finished spells from current pointers
|
// remove finished spells from current pointers
|
||||||
for (uint32 i = 0; i < CURRENT_MAX_SPELL; i++)
|
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
|
||||||
{
|
{
|
||||||
if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
|
if (m_currentSpells[i] && m_currentSpells[i]->getState() == SPELL_STATE_FINISHED)
|
||||||
{
|
{
|
||||||
@@ -3371,20 +3370,18 @@ void Unit::_UpdateSpells( uint32 time )
|
|||||||
|
|
||||||
if(!m_gameObj.empty())
|
if(!m_gameObj.empty())
|
||||||
{
|
{
|
||||||
GameObjectList::iterator ite1, dnext1;
|
GameObjectList::iterator itr;
|
||||||
for (ite1 = m_gameObj.begin(); ite1 != m_gameObj.end(); ite1 = dnext1)
|
for(itr = m_gameObj.begin(); itr != m_gameObj.end();)
|
||||||
{
|
{
|
||||||
dnext1 = ite1;
|
if( !(*itr)->isSpawned() )
|
||||||
//(*i)->Update( difftime );
|
|
||||||
if( !(*ite1)->isSpawned() )
|
|
||||||
{
|
{
|
||||||
(*ite1)->SetOwnerGUID(0);
|
(*itr)->SetOwnerGUID(0);
|
||||||
(*ite1)->SetRespawnTime(0);
|
(*itr)->SetRespawnTime(0);
|
||||||
(*ite1)->Delete();
|
(*itr)->Delete();
|
||||||
dnext1 = m_gameObj.erase(ite1);
|
m_gameObj.erase(itr++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
++dnext1;
|
++itr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user