diff options
-rw-r--r-- | src/game/SpellAuras.cpp | 22 | ||||
-rw-r--r-- | src/game/Unit.cpp | 27 |
2 files changed, 25 insertions, 24 deletions
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 6d446896b67..0d4606e6e84 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -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) : 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) { assert(target); @@ -356,6 +356,9 @@ m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1),m_aura m_spellProto = spellproto; + if(m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel) + m_timeCla = 1000; + m_isPassive = IsPassiveSpell(GetId()); m_auraStateMask = 0; @@ -627,15 +630,15 @@ void Aura::Update(uint32 diff) m_duration = 0; // all spells with manaPerSecond/manaPerSecondPerLevel have aura in effect 0 - if(m_timeCla > 0) - m_timeCla -= diff; - if(m_timeCla <= 0) + if(m_timeCla) { - 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()) { - m_timeCla = 1000; + m_timeCla += 1000 - diff; Powers powertype = Powers(m_spellProto->powerType); if(powertype == POWER_HEALTH) @@ -672,13 +675,14 @@ void AuraEffect::Update(uint32 diff) { if (m_isPeriodic && (GetParentAura()->GetAuraDuration() >=0 || GetParentAura()->IsPassive() || GetParentAura()->IsPermanent())) { - 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 + if(m_periodicTimer > diff) + 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; // 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)) PeriodicTick(); diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 848fff13113..2b9f17b1402 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -3305,12 +3305,11 @@ uint32 Unit::GetWeaponSkillValue (WeaponAttackType attType, Unit const* target) 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; - sLog.outDebug("Aura %d is deleted from unit %d", Aur->GetId(), GetGUIDLow()); + delete m_removedAuras.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(); // 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) { @@ -3371,20 +3370,18 @@ void Unit::_UpdateSpells( uint32 time ) if(!m_gameObj.empty()) { - GameObjectList::iterator ite1, dnext1; - for (ite1 = m_gameObj.begin(); ite1 != m_gameObj.end(); ite1 = dnext1) + GameObjectList::iterator itr; + for(itr = m_gameObj.begin(); itr != m_gameObj.end();) { - dnext1 = ite1; - //(*i)->Update( difftime ); - if( !(*ite1)->isSpawned() ) + if( !(*itr)->isSpawned() ) { - (*ite1)->SetOwnerGUID(0); - (*ite1)->SetRespawnTime(0); - (*ite1)->Delete(); - dnext1 = m_gameObj.erase(ite1); + (*itr)->SetOwnerGUID(0); + (*itr)->SetRespawnTime(0); + (*itr)->Delete(); + m_gameObj.erase(itr++); } else - ++dnext1; + ++itr; } } } |