aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp23
-rw-r--r--src/server/game/Entities/Player/Player.cpp25
-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, 81 deletions
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 7ee837ce1bf..e1e9dc36497 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -1298,19 +1298,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 ed762c0ebd0..ad221fa38bf 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -19416,20 +19416,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 ba3e3dab805..7b5e0d85043 100644
--- a/src/server/game/Entities/Unit/StatSystem.cpp
+++ b/src/server/game/Entities/Unit/StatSystem.cpp
@@ -683,9 +683,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 ca6ee19873f..ec61bf59721 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -13884,13 +13884,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 25393445918..08733f5919a 100644
--- a/src/server/game/Server/Packets/PartyPackets.cpp
+++ b/src/server/game/Server/Packets/PartyPackets.cpp
@@ -646,25 +646,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
@@ -686,25 +677,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 210d14edc40..bd31934704c 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)
@@ -278,11 +278,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())
@@ -294,7 +294,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());
}
}
@@ -821,8 +821,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)
@@ -1048,8 +1047,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())
@@ -1263,9 +1261,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);
@@ -1276,11 +1271,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;
}
@@ -1307,7 +1301,7 @@ void Aura::RecalculateAmountOfEffects()
ASSERT (!IsRemoved());
Unit* caster = GetCaster();
for (AuraEffect* effect : GetAuraEffects())
- if (effect && !IsRemoved())
+ if (!IsRemoved())
effect->RecalculateAmount(caster);
}
@@ -1315,16 +1309,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 107dd2fe0e6..ee43c84e681 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 fb4e5a00c1e..2d299e28296 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)