aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp23
-rw-r--r--src/server/game/Entities/Player/Player.cpp30
-rw-r--r--src/server/game/Entities/Unit/StatSystem.cpp3
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp5
-rw-r--r--src/server/game/Server/Packets/PartyPackets.cpp22
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp37
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h16
-rw-r--r--src/server/game/Spells/Spell.cpp5
8 files changed, 55 insertions, 86 deletions
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 534232ada4f..c1248c88be1 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -1329,19 +1329,16 @@ void Pet::_SaveAuras(CharacterDatabaseTransaction trans)
for (AuraEffect const* effect : aura->GetAuraEffects())
{
- if (effect)
- {
- index = 0;
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA_EFFECT);
- stmt->setUInt32(index++, m_charmInfo->GetPetNumber());
- stmt->setBinary(index++, key.Caster.GetRawValue());
- stmt->setUInt32(index++, key.SpellId);
- stmt->setUInt32(index++, key.EffectMask);
- stmt->setUInt8(index++, effect->GetEffIndex());
- stmt->setInt32(index++, effect->GetAmount());
- stmt->setInt32(index++, effect->GetBaseAmount());
- trans->Append(stmt);
- }
+ index = 0;
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA_EFFECT);
+ stmt->setUInt32(index++, m_charmInfo->GetPetNumber());
+ stmt->setBinary(index++, key.Caster.GetRawValue());
+ stmt->setUInt32(index++, key.SpellId);
+ stmt->setUInt32(index++, key.EffectMask);
+ stmt->setUInt8(index++, effect->GetEffIndex());
+ stmt->setInt32(index++, effect->GetAmount());
+ stmt->setInt32(index++, effect->GetBaseAmount());
+ trans->Append(stmt);
}
}
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 670970e2536..269678cf9ba 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -8552,13 +8552,8 @@ void Player::ApplyArtifactPowerRank(Item* artifact, ArtifactPowerRankEntry const
if (apply)
{
for (AuraEffect* auraEffect : powerAura->GetBase()->GetAuraEffects())
- {
- if (!auraEffect)
- continue;
-
if (powerAura->HasEffect(auraEffect->GetEffIndex()))
auraEffect->ChangeAmount(artifactPowerRank->AuraPointsOverride ? artifactPowerRank->AuraPointsOverride : auraEffect->GetSpellEffectInfo().CalcValue());
- }
}
else
RemoveAura(powerAura);
@@ -20827,20 +20822,17 @@ void Player::_SaveAuras(CharacterDatabaseTransaction trans)
for (AuraEffect const* effect : aura->GetAuraEffects())
{
- if (effect)
- {
- index = 0;
- stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA_EFFECT);
- stmt->setUInt64(index++, GetGUID().GetCounter());
- stmt->setBinary(index++, key.Caster.GetRawValue());
- stmt->setBinary(index++, key.Item.GetRawValue());
- stmt->setUInt32(index++, key.SpellId);
- stmt->setUInt32(index++, key.EffectMask);
- stmt->setUInt8(index++, effect->GetEffIndex());
- stmt->setInt32(index++, effect->GetAmount());
- stmt->setInt32(index++, effect->GetBaseAmount());
- trans->Append(stmt);
- }
+ index = 0;
+ stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AURA_EFFECT);
+ stmt->setUInt64(index++, GetGUID().GetCounter());
+ stmt->setBinary(index++, key.Caster.GetRawValue());
+ stmt->setBinary(index++, key.Item.GetRawValue());
+ stmt->setUInt32(index++, key.SpellId);
+ stmt->setUInt32(index++, key.EffectMask);
+ stmt->setUInt8(index++, effect->GetEffIndex());
+ stmt->setInt32(index++, effect->GetAmount());
+ stmt->setInt32(index++, effect->GetBaseAmount());
+ trans->Append(stmt);
}
}
}
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp
index 4067c41a05c..bedb30bf968 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -556,9 +556,6 @@ void Player::UpdateMastery()
{
for (AuraEffect* auraEff : aura->GetAuraEffects())
{
- if (!auraEff)
- continue;
-
float mult = auraEff->GetSpellEffectInfo().BonusCoefficient;
if (G3D::fuzzyEq(mult, 0.0f))
continue;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 73167038f7b..89c1afbeae4 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -13888,13 +13888,8 @@ int32 Unit::GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEf
bool Unit::IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications /*= false*/)
{
for (AuraEffect const* aurEff : aura->GetAuraEffects())
- {
- if (!aurEff)
- continue;
-
if (!IsHighestExclusiveAuraEffect(aura->GetSpellInfo(), aurEff->GetAuraType(), aurEff->GetAmount(), aura->GetEffectMask(), removeOtherAuraApplications))
return false;
- }
return true;
}
diff --git a/src/server/game/Server/Packets/PartyPackets.cpp b/src/server/game/Server/Packets/PartyPackets.cpp
index 90fccd9512d..c21f99b1eb0 100644
--- a/src/server/game/Server/Packets/PartyPackets.cpp
+++ b/src/server/game/Server/Packets/PartyPackets.cpp
@@ -648,25 +648,16 @@ void WorldPackets::Party::PartyMemberFullState::Initialize(Player const* player)
// Auras
for (AuraApplication const* aurApp : player->GetVisibleAuras())
{
- WorldPackets::Party::PartyMemberAuraStates aura;
+ PartyMemberAuraStates& aura = MemberStats.Auras.emplace_back();
aura.SpellID = aurApp->GetBase()->GetId();
aura.ActiveFlags = aurApp->GetEffectMask();
aura.Flags = aurApp->GetFlags();
if (aurApp->GetFlags() & AFLAG_SCALABLE)
- {
for (AuraEffect const* aurEff : aurApp->GetBase()->GetAuraEffects())
- {
- if (!aurEff)
- continue;
-
if (aurApp->HasEffect(aurEff->GetEffIndex()))
aura.Points.push_back(float(aurEff->GetAmount()));
- }
- }
-
- MemberStats.Auras.push_back(aura);
}
// Phases
@@ -688,25 +679,16 @@ void WorldPackets::Party::PartyMemberFullState::Initialize(Player const* player)
for (AuraApplication const* aurApp : pet->GetVisibleAuras())
{
- WorldPackets::Party::PartyMemberAuraStates aura;
+ PartyMemberAuraStates aura = MemberStats.PetStats->Auras.emplace_back();
aura.SpellID = aurApp->GetBase()->GetId();
aura.ActiveFlags = aurApp->GetEffectMask();
aura.Flags = aurApp->GetFlags();
if (aurApp->GetFlags() & AFLAG_SCALABLE)
- {
for (AuraEffect const* aurEff : aurApp->GetBase()->GetAuraEffects())
- {
- if (!aurEff)
- continue;
-
if (aurApp->HasEffect(aurEff->GetEffIndex()))
aura.Points.push_back(float(aurEff->GetAmount()));
- }
- }
-
- MemberStats.PetStats->Auras.push_back(aura);
}
}
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 9a21e6514fd..90cb347b578 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -119,7 +119,7 @@ void AuraApplication::_InitFlags(Unit* caster, uint32 effMask)
if (IsSelfcast() || !caster || !caster->IsFriendlyTo(GetTarget()))
{
bool negativeFound = false;
- for (uint8 i = 0; i < GetBase()->GetSpellInfo()->GetEffects().size(); ++i)
+ for (uint8 i = 0; i < GetBase()->GetAuraEffectCount(); ++i)
{
if (((1 << i) & effMask) && !GetBase()->GetSpellInfo()->IsPositiveEffect(i))
{
@@ -134,7 +134,7 @@ void AuraApplication::_InitFlags(Unit* caster, uint32 effMask)
else
{
bool positiveFound = false;
- for (uint8 i = 0; i < GetBase()->GetSpellInfo()->GetEffects().size(); ++i)
+ for (uint8 i = 0; i < GetBase()->GetAuraEffectCount(); ++i)
{
if (((1 << i) & effMask) && GetBase()->GetSpellInfo()->IsPositiveEffect(i))
{
@@ -147,7 +147,7 @@ void AuraApplication::_InitFlags(Unit* caster, uint32 effMask)
auto effectNeedsAmount = [this](AuraEffect const* effect)
{
- return effect && (GetEffectsToApply() & (1 << effect->GetEffIndex())) && Aura::EffectTypeNeedsSendingAmount(effect->GetAuraType());
+ return GetEffectsToApply() & (1 << effect->GetEffIndex()) && Aura::EffectTypeNeedsSendingAmount(effect->GetAuraType());
};
if (GetBase()->GetSpellInfo()->HasAttribute(SPELL_ATTR8_AURA_POINTS_ON_CLIENT)
@@ -271,11 +271,11 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo
if (auraData.Flags & AFLAG_SCALABLE)
{
- auraData.Points.reserve(aura->GetAuraEffects().size());
+ auraData.Points.reserve(aura->GetAuraEffectCount());
bool hasEstimatedAmounts = false;
for (AuraEffect const* effect : GetBase()->GetAuraEffects())
{
- if (effect && HasEffect(effect->GetEffIndex())) // Not all of aura's effects have to be applied on every target
+ if (HasEffect(effect->GetEffIndex())) // Not all of aura's effects have to be applied on every target
{
Trinity::Containers::EnsureWritableVectorIndex(auraData.Points, effect->GetEffIndex()) = float(effect->GetAmount());
if (effect->GetEstimatedAmount())
@@ -287,7 +287,7 @@ void AuraApplication::BuildUpdatePacket(WorldPackets::Spells::AuraInfo& auraInfo
// When sending EstimatedPoints all effects (at least up to the last one that uses GetEstimatedAmount) must have proper value in packet
auraData.EstimatedPoints.resize(auraData.Points.size());
for (AuraEffect const* effect : GetBase()->GetAuraEffects())
- if (effect && HasEffect(effect->GetEffIndex())) // Not all of aura's effects have to be applied on every target
+ if (HasEffect(effect->GetEffIndex())) // Not all of aura's effects have to be applied on every target
auraData.EstimatedPoints[effect->GetEffIndex()] = effect->GetEstimatedAmount().value_or(effect->GetAmount());
}
}
@@ -814,8 +814,7 @@ void Aura::UpdateOwner(uint32 diff, WorldObject* owner)
// update aura effects
for (AuraEffect* effect : GetAuraEffects())
- if (effect)
- effect->Update(diff, caster);
+ effect->Update(diff, caster);
// remove spellmods after effects update
if (modSpell)
@@ -1047,8 +1046,7 @@ void Aura::SetStackAmount(uint8 stackAmount)
HandleAuraSpecificMods(aurApp, caster, false, true);
for (AuraEffect* aurEff : GetAuraEffects())
- if (aurEff)
- aurEff->ChangeAmount(aurEff->CalculateAmount(caster), false, true);
+ aurEff->ChangeAmount(aurEff->CalculateAmount(caster), false, true);
for (AuraApplication* aurApp : applications)
if (!aurApp->GetRemoveMode())
@@ -1262,9 +1260,6 @@ void Aura::SetLoadedState(int32 maxDuration, int32 duration, int32 charges, uint
Unit* caster = GetCaster();
for (AuraEffect* effect : GetAuraEffects())
{
- if (!effect)
- continue;
-
effect->SetAmount(amount[effect->GetEffIndex()]);
effect->SetCanBeRecalculated((recalculateMask & (1 << effect->GetEffIndex())) != 0);
effect->CalculatePeriodic(caster, false, true);
@@ -1275,11 +1270,10 @@ void Aura::SetLoadedState(int32 maxDuration, int32 duration, int32 charges, uint
bool Aura::HasEffectType(AuraType type) const
{
- for (AuraEffect* effect : GetAuraEffects())
- {
- if (effect && effect->GetAuraType() == type)
+ for (AuraEffect const* effect : GetAuraEffects())
+ if (effect->GetAuraType() == type)
return true;
- }
+
return false;
}
@@ -1306,7 +1300,7 @@ void Aura::RecalculateAmountOfEffects()
ASSERT (!IsRemoved());
Unit* caster = GetCaster();
for (AuraEffect* effect : GetAuraEffects())
- if (effect && !IsRemoved())
+ if (!IsRemoved())
effect->RecalculateAmount(caster);
}
@@ -1314,16 +1308,15 @@ void Aura::HandleAllEffects(AuraApplication * aurApp, uint8 mode, bool apply)
{
ASSERT (!IsRemoved());
for (AuraEffect* effect : GetAuraEffects())
- if (effect && !IsRemoved())
+ if (!IsRemoved())
effect->HandleEffect(aurApp, mode, apply);
}
uint32 Aura::GetEffectMask() const
{
uint32 effMask = 0;
- for (AuraEffect* aurEff : GetAuraEffects())
- if (aurEff)
- effMask |= 1 << aurEff->GetEffIndex();
+ for (AuraEffect const* aurEff : GetAuraEffects())
+ effMask |= 1 << aurEff->GetEffIndex();
return effMask;
}
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index 9f46f295fdb..208c966bd58 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -18,6 +18,8 @@
#ifndef TRINITY_SPELLAURAS_H
#define TRINITY_SPELLAURAS_H
+#include "DBStorageIterator.h"
+#include "IteratorPair.h"
#include "SpellAuraDefines.h"
#include "SpellInfo.h"
#include "UniqueTrackablePtr.h"
@@ -308,7 +310,19 @@ class TC_GAME_API Aura
std::vector<AuraScript*> m_loadedScripts;
- AuraEffectVector const& GetAuraEffects() const { return _effects; }
+ Trinity::IteratorPair<DBStorageIterator<AuraEffect*>> GetAuraEffects()
+ {
+ return Trinity::Containers::MakeIteratorPair(
+ DBStorageIterator(_effects.data(), _effects.size()),
+ DBStorageIterator(_effects.data(), _effects.size(), _effects.size()));
+ }
+ Trinity::IteratorPair<DBStorageIterator<AuraEffect const*>> GetAuraEffects() const
+ {
+ return Trinity::Containers::MakeIteratorPair(
+ DBStorageIterator<AuraEffect const*>(_effects.data(), _effects.size()),
+ DBStorageIterator<AuraEffect const*>(_effects.data(), _effects.size(), _effects.size()));
+ }
+ std::size_t GetAuraEffectCount() const { return _effects.size(); }
virtual std::string GetDebugInfo() const;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 170e5006ee2..09828f515f5 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -3284,9 +3284,8 @@ void Spell::DoSpellEffectHit(Unit* unit, SpellEffectInfo const& spellEffectInfo,
int32 origDuration = hitInfo.AuraDuration;
hitInfo.AuraDuration = 0;
for (AuraEffect const* auraEff : hitInfo.HitAura->GetAuraEffects())
- if (auraEff)
- if (int32 period = auraEff->GetPeriod()) // period is hastened by UNIT_MOD_CAST_SPEED
- hitInfo.AuraDuration = std::max(std::max(origDuration / period, 1) * period, hitInfo.AuraDuration);
+ if (int32 period = auraEff->GetPeriod()) // period is hastened by UNIT_MOD_CAST_SPEED
+ hitInfo.AuraDuration = std::max(std::max(origDuration / period, 1) * period, hitInfo.AuraDuration);
// if there is no periodic effect
if (!hitInfo.AuraDuration)