mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 02:25:38 +01:00
Core/Misc: DBC std::array refactors, and |Hachievement unit tests
(cherry picked from commit 3fbbe7cfbe)
This commit is contained in:
@@ -216,8 +216,8 @@ uint32 SpellImplicitTargetInfo::GetExplicitTargetMask(bool& srcSet, bool& dstSet
|
||||
return targetMask;
|
||||
}
|
||||
|
||||
SpellImplicitTargetInfo::StaticData SpellImplicitTargetInfo::_data[TOTAL_SPELL_TARGETS] =
|
||||
{
|
||||
std::array<SpellImplicitTargetInfo::StaticData, TOTAL_SPELL_TARGETS> SpellImplicitTargetInfo::_data =
|
||||
{ {
|
||||
{TARGET_OBJECT_TYPE_NONE, TARGET_REFERENCE_TYPE_NONE, TARGET_SELECT_CATEGORY_NYI, TARGET_CHECK_DEFAULT, TARGET_DIR_NONE}, //
|
||||
{TARGET_OBJECT_TYPE_UNIT, TARGET_REFERENCE_TYPE_CASTER, TARGET_SELECT_CATEGORY_DEFAULT, TARGET_CHECK_DEFAULT, TARGET_DIR_NONE}, // 1 TARGET_UNIT_CASTER
|
||||
{TARGET_OBJECT_TYPE_UNIT, TARGET_REFERENCE_TYPE_CASTER, TARGET_SELECT_CATEGORY_NEARBY, TARGET_CHECK_ENEMY, TARGET_DIR_NONE}, // 2 TARGET_UNIT_NEARBY_ENEMY
|
||||
@@ -370,7 +370,7 @@ SpellImplicitTargetInfo::StaticData SpellImplicitTargetInfo::_data[TOTAL_SPELL_T
|
||||
{TARGET_OBJECT_TYPE_DEST, TARGET_REFERENCE_TYPE_CASTER, TARGET_SELECT_CATEGORY_DEFAULT, TARGET_CHECK_DEFAULT, TARGET_DIR_RANDOM}, // 149
|
||||
{TARGET_OBJECT_TYPE_UNIT, TARGET_REFERENCE_TYPE_CASTER, TARGET_SELECT_CATEGORY_DEFAULT, TARGET_CHECK_DEFAULT, TARGET_DIR_NONE}, // 150 TARGET_UNIT_OWN_CRITTER
|
||||
{TARGET_OBJECT_TYPE_UNIT, TARGET_REFERENCE_TYPE_CASTER, TARGET_SELECT_CATEGORY_AREA, TARGET_CHECK_ENEMY, TARGET_DIR_NONE}, // 151
|
||||
};
|
||||
} };
|
||||
|
||||
SpellEffectInfo::SpellEffectInfo(SpellInfo const* spellInfo, SpellEffectEntry const& _effect)
|
||||
: EffectAttributes(SpellEffectAttributes::None)
|
||||
@@ -781,8 +781,8 @@ ExpectedStatType SpellEffectInfo::GetScalingExpectedStat() const
|
||||
return ExpectedStatType::None;
|
||||
}
|
||||
|
||||
SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] =
|
||||
{
|
||||
std::array<SpellEffectInfo::StaticData, TOTAL_SPELL_EFFECTS> SpellEffectInfo::_data =
|
||||
{ {
|
||||
// implicit target type used target object type
|
||||
{EFFECT_IMPLICIT_TARGET_NONE, TARGET_OBJECT_TYPE_NONE}, // 0
|
||||
{EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 1 SPELL_EFFECT_INSTAKILL
|
||||
@@ -1072,7 +1072,7 @@ SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] =
|
||||
{EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 285 SPELL_EFFECT_MODIFY_KEYSTONE_2
|
||||
{EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 284 SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE
|
||||
{EFFECT_IMPLICIT_TARGET_NONE, TARGET_OBJECT_TYPE_NONE}, // 285 SPELL_EFFECT_SET_GARRISON_FOLLOWER_LEVEL
|
||||
};
|
||||
} };
|
||||
|
||||
SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, SpellInfoLoadHelper const& data)
|
||||
: Id(spellName->ID), Difficulty(difficulty)
|
||||
@@ -1230,8 +1230,8 @@ SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, S
|
||||
// SpellReagentsEntry
|
||||
if (SpellReagentsEntry const* _reagents = data.Reagents)
|
||||
{
|
||||
std::copy(std::begin(_reagents->Reagent), std::end(_reagents->Reagent), Reagent.begin());
|
||||
std::copy(std::begin(_reagents->ReagentCount), std::end(_reagents->ReagentCount), ReagentCount.begin());
|
||||
Reagent = _reagents->Reagent;
|
||||
ReagentCount = _reagents->ReagentCount;
|
||||
}
|
||||
|
||||
ReagentsCurrency = data.ReagentsCurrency;
|
||||
@@ -1257,8 +1257,8 @@ SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, S
|
||||
// SpellTotemsEntry
|
||||
if (SpellTotemsEntry const* _totem = data.Totems)
|
||||
{
|
||||
std::copy(std::begin(_totem->RequiredTotemCategoryID), std::end(_totem->RequiredTotemCategoryID), TotemCategory.begin());
|
||||
std::copy(std::begin(_totem->Totem), std::end(_totem->Totem), Totem.begin());
|
||||
TotemCategory = _totem->RequiredTotemCategoryID;
|
||||
Totem = _totem->Totem;
|
||||
}
|
||||
|
||||
_visuals = data.Visuals;
|
||||
@@ -3497,9 +3497,9 @@ void SpellInfo::_LoadImmunityInfo()
|
||||
|
||||
void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& spellEffectInfo, bool apply) const
|
||||
{
|
||||
ImmunityInfo const* immuneInfo = spellEffectInfo.GetImmunityInfo();
|
||||
ImmunityInfo const& immuneInfo = spellEffectInfo.GetImmunityInfo();
|
||||
|
||||
if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
|
||||
if (uint32 schoolImmunity = immuneInfo.SchoolImmuneMask)
|
||||
{
|
||||
target->ApplySpellImmune(Id, IMMUNITY_SCHOOL, schoolImmunity, apply);
|
||||
|
||||
@@ -3520,7 +3520,7 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& s
|
||||
target->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::InvulnerabilityBuff);
|
||||
}
|
||||
|
||||
if (uint32 mechanicImmunity = immuneInfo->MechanicImmuneMask)
|
||||
if (uint32 mechanicImmunity = immuneInfo.MechanicImmuneMask)
|
||||
{
|
||||
for (uint32 i = 0; i < MAX_MECHANIC; ++i)
|
||||
if (mechanicImmunity & (1 << i))
|
||||
@@ -3530,7 +3530,7 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& s
|
||||
target->RemoveAurasWithMechanic(mechanicImmunity, AURA_REMOVE_BY_DEFAULT, Id);
|
||||
}
|
||||
|
||||
if (uint32 dispelImmunity = immuneInfo->DispelImmune)
|
||||
if (uint32 dispelImmunity = immuneInfo.DispelImmune)
|
||||
{
|
||||
target->ApplySpellImmune(Id, IMMUNITY_DISPEL, dispelImmunity, apply);
|
||||
|
||||
@@ -3547,7 +3547,7 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& s
|
||||
}
|
||||
}
|
||||
|
||||
if (uint32 damageImmunity = immuneInfo->DamageSchoolMask)
|
||||
if (uint32 damageImmunity = immuneInfo.DamageSchoolMask)
|
||||
{
|
||||
target->ApplySpellImmune(Id, IMMUNITY_DAMAGE, damageImmunity, apply);
|
||||
|
||||
@@ -3555,14 +3555,14 @@ void SpellInfo::ApplyAllSpellImmunitiesTo(Unit* target, SpellEffectInfo const& s
|
||||
target->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::InvulnerabilityBuff);
|
||||
}
|
||||
|
||||
for (AuraType auraType : immuneInfo->AuraTypeImmune)
|
||||
for (AuraType auraType : immuneInfo.AuraTypeImmune)
|
||||
{
|
||||
target->ApplySpellImmune(Id, IMMUNITY_STATE, auraType, apply);
|
||||
if (apply && HasAttribute(SPELL_ATTR1_DISPEL_AURAS_ON_IMMUNITY))
|
||||
target->RemoveAurasByType(auraType);
|
||||
}
|
||||
|
||||
for (SpellEffectName effectType : immuneInfo->SpellEffectImmune)
|
||||
for (SpellEffectName effectType : immuneInfo.SpellEffectImmune)
|
||||
target->ApplySpellImmune(Id, IMMUNITY_EFFECT, effectType, apply);
|
||||
}
|
||||
|
||||
@@ -3576,20 +3576,20 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
|
||||
if (!effectInfo.IsEffect())
|
||||
continue;
|
||||
|
||||
ImmunityInfo const* immuneInfo = effectInfo.GetImmunityInfo();
|
||||
ImmunityInfo const& immuneInfo = effectInfo.GetImmunityInfo();
|
||||
|
||||
if (!auraSpellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) && !auraSpellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
|
||||
{
|
||||
if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
|
||||
if (uint32 schoolImmunity = immuneInfo.SchoolImmuneMask)
|
||||
if ((auraSpellInfo->SchoolMask & schoolImmunity) != 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (uint32 mechanicImmunity = immuneInfo->MechanicImmuneMask)
|
||||
if (uint32 mechanicImmunity = immuneInfo.MechanicImmuneMask)
|
||||
if ((mechanicImmunity & (1 << auraSpellInfo->Mechanic)) != 0)
|
||||
return true;
|
||||
|
||||
if (uint32 dispelImmunity = immuneInfo->DispelImmune)
|
||||
if (uint32 dispelImmunity = immuneInfo.DispelImmune)
|
||||
if (auraSpellInfo->Dispel == dispelImmunity)
|
||||
return true;
|
||||
|
||||
@@ -3599,8 +3599,8 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
|
||||
if (!auraSpellEffectInfo.IsEffect())
|
||||
continue;
|
||||
|
||||
auto spellImmuneItr = immuneInfo->SpellEffectImmune.find(auraSpellEffectInfo.Effect);
|
||||
if (spellImmuneItr == immuneInfo->SpellEffectImmune.cend())
|
||||
auto spellImmuneItr = immuneInfo.SpellEffectImmune.find(auraSpellEffectInfo.Effect);
|
||||
if (spellImmuneItr == immuneInfo.SpellEffectImmune.cend())
|
||||
{
|
||||
immuneToAllEffects = false;
|
||||
break;
|
||||
@@ -3608,7 +3608,7 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
|
||||
|
||||
if (uint32 mechanic = auraSpellEffectInfo.Mechanic)
|
||||
{
|
||||
if (!(immuneInfo->MechanicImmuneMask & (1 << mechanic)))
|
||||
if (!(immuneInfo.MechanicImmuneMask & (1 << mechanic)))
|
||||
{
|
||||
immuneToAllEffects = false;
|
||||
break;
|
||||
@@ -3620,13 +3620,13 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
|
||||
if (AuraType auraName = auraSpellEffectInfo.ApplyAuraName)
|
||||
{
|
||||
bool isImmuneToAuraEffectApply = false;
|
||||
auto auraImmuneItr = immuneInfo->AuraTypeImmune.find(auraName);
|
||||
if (auraImmuneItr != immuneInfo->AuraTypeImmune.cend())
|
||||
auto auraImmuneItr = immuneInfo.AuraTypeImmune.find(auraName);
|
||||
if (auraImmuneItr != immuneInfo.AuraTypeImmune.cend())
|
||||
isImmuneToAuraEffectApply = true;
|
||||
|
||||
if (!isImmuneToAuraEffectApply && !auraSpellInfo->IsPositiveEffect(auraSpellEffectInfo.EffectIndex) && !auraSpellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE))
|
||||
{
|
||||
if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
|
||||
if (uint32 applyHarmfulAuraImmunityMask = immuneInfo.ApplyHarmfulAuraImmuneMask)
|
||||
if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
|
||||
isImmuneToAuraEffectApply = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user