aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellInfo.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-03-12 21:59:10 +0100
committerShauren <shauren.trinity@gmail.com>2021-03-12 21:59:10 +0100
commit2bd70b41eb0d2d2aad16ddb17525c2f24acde2c5 (patch)
tree0c740f968e5b8e1a1154e2f058a1b55ae2b94e95 /src/server/game/Spells/SpellInfo.cpp
parentefdca47aff354079bc73d248e022c2e914d94e7b (diff)
Core/Spells: Restore serverside spells fuinctionality
Diffstat (limited to 'src/server/game/Spells/SpellInfo.cpp')
-rw-r--r--src/server/game/Spells/SpellInfo.cpp308
1 files changed, 165 insertions, 143 deletions
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 2e6c6acb76f..53a732c1390 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -371,41 +371,40 @@ SpellImplicitTargetInfo::StaticData SpellImplicitTargetInfo::_data[TOTAL_SPELL_
{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)
+SpellEffectInfo::SpellEffectInfo(SpellInfo const* spellInfo, SpellEffectEntry const& _effect)
: EffectAttributes(SpellEffectAttributes::None)
{
ASSERT(spellInfo);
- ASSERT(_effect);
_spellInfo = spellInfo;
- EffectIndex = _effect->EffectIndex;
- Effect = _effect->Effect;
- ApplyAuraName = _effect->EffectAura;
- ApplyAuraPeriod = _effect->EffectAuraPeriod;
- RealPointsPerLevel = _effect->EffectRealPointsPerLevel;
- BasePoints = _effect->EffectBasePoints;
- PointsPerResource = _effect->EffectPointsPerResource;
- Amplitude = _effect->EffectAmplitude;
- ChainAmplitude = _effect->EffectChainAmplitude;
- BonusCoefficient = _effect->EffectBonusCoefficient;
- MiscValue = _effect->EffectMiscValue[0];
- MiscValueB = _effect->EffectMiscValue[1];
- Mechanic = Mechanics(_effect->EffectMechanic);
- PositionFacing = _effect->EffectPosFacing;
- TargetA = SpellImplicitTargetInfo(_effect->ImplicitTarget[0]);
- TargetB = SpellImplicitTargetInfo(_effect->ImplicitTarget[1]);
- RadiusEntry = sSpellRadiusStore.LookupEntry(_effect->EffectRadiusIndex[0]);
- MaxRadiusEntry = sSpellRadiusStore.LookupEntry(_effect->EffectRadiusIndex[1]);
- ChainTargets = _effect->EffectChainTargets;
- ItemType = _effect->EffectItemType;
- TriggerSpell = _effect->EffectTriggerSpell;
- SpellClassMask = _effect->EffectSpellClassMask;
- BonusCoefficientFromAP = _effect->BonusCoefficientFromAP;
- Scaling.Coefficient = _effect->Coefficient;
- Scaling.Variance = _effect->Variance;
- Scaling.ResourceCoefficient = _effect->ResourceCoefficient;
+ EffectIndex = _effect.EffectIndex;
+ Effect = _effect.Effect;
+ ApplyAuraName = _effect.EffectAura;
+ ApplyAuraPeriod = _effect.EffectAuraPeriod;
+ BasePoints = _effect.EffectBasePoints;
+ RealPointsPerLevel = _effect.EffectRealPointsPerLevel;
+ PointsPerResource = _effect.EffectPointsPerResource;
+ Amplitude = _effect.EffectAmplitude;
+ ChainAmplitude = _effect.EffectChainAmplitude;
+ BonusCoefficient = _effect.EffectBonusCoefficient;
+ MiscValue = _effect.EffectMiscValue[0];
+ MiscValueB = _effect.EffectMiscValue[1];
+ Mechanic = Mechanics(_effect.EffectMechanic);
+ PositionFacing = _effect.EffectPosFacing;
+ TargetA = SpellImplicitTargetInfo(_effect.ImplicitTarget[0]);
+ TargetB = SpellImplicitTargetInfo(_effect.ImplicitTarget[1]);
+ RadiusEntry = sSpellRadiusStore.LookupEntry(_effect.EffectRadiusIndex[0]);
+ MaxRadiusEntry = sSpellRadiusStore.LookupEntry(_effect.EffectRadiusIndex[1]);
+ ChainTargets = _effect.EffectChainTargets;
+ ItemType = _effect.EffectItemType;
+ TriggerSpell = _effect.EffectTriggerSpell;
+ SpellClassMask = _effect.EffectSpellClassMask;
+ BonusCoefficientFromAP = _effect.BonusCoefficientFromAP;
+ Scaling.Coefficient = _effect.Coefficient;
+ Scaling.Variance = _effect.Variance;
+ Scaling.ResourceCoefficient = _effect.ResourceCoefficient;
ImplicitTargetConditions = nullptr;
- EffectAttributes = _effect->GetEffectAttributes();
+ EffectAttributes = _effect.GetEffectAttributes();
}
bool SpellEffectInfo::IsEffect() const
@@ -1081,10 +1080,8 @@ SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] =
};
SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, SpellInfoLoadHelper const& data, SpellVisualVector&& visuals)
+ : Id(spellName->ID), Difficulty(difficulty)
{
- Id = spellName->ID;
- Difficulty = difficulty;
-
_effects.reserve(32);
for (SpellEffectEntry const* spellEffect : data.Effects)
{
@@ -1094,106 +1091,123 @@ SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, S
if (uint32(spellEffect->EffectIndex) >= _effects.size())
_effects.resize(spellEffect->EffectIndex + 1);
- _effects[spellEffect->EffectIndex] = new SpellEffectInfo(this, spellEffect);
+ _effects[spellEffect->EffectIndex] = new SpellEffectInfo(this, *spellEffect);
}
_effects.shrink_to_fit();
SpellName = &spellName->Name;
// SpellMiscEntry
- SpellMiscEntry const* _misc = data.Misc;
- Attributes = _misc ? _misc->Attributes[0] : 0;
- AttributesEx = _misc ? _misc->Attributes[1] : 0;
- AttributesEx2 = _misc ? _misc->Attributes[2] : 0;
- AttributesEx3 = _misc ? _misc->Attributes[3] : 0;
- AttributesEx4 = _misc ? _misc->Attributes[4] : 0;
- AttributesEx5 = _misc ? _misc->Attributes[5] : 0;
- AttributesEx6 = _misc ? _misc->Attributes[6] : 0;
- AttributesEx7 = _misc ? _misc->Attributes[7] : 0;
- AttributesEx8 = _misc ? _misc->Attributes[8] : 0;
- AttributesEx9 = _misc ? _misc->Attributes[9] : 0;
- AttributesEx10 = _misc ? _misc->Attributes[10] : 0;
- AttributesEx11 = _misc ? _misc->Attributes[11] : 0;
- AttributesEx12 = _misc ? _misc->Attributes[12] : 0;
- AttributesEx13 = _misc ? _misc->Attributes[13] : 0;
- AttributesEx14 = _misc ? _misc->Attributes[14] : 0;
- CastTimeEntry = _misc ? (_misc->CastingTimeIndex ? sSpellCastTimesStore.LookupEntry(_misc->CastingTimeIndex) : nullptr) : nullptr;
- DurationEntry = _misc ? (_misc->DurationIndex ? sSpellDurationStore.LookupEntry(_misc->DurationIndex) : nullptr) : nullptr;
- RangeIndex = _misc ? _misc->RangeIndex : 0;
- RangeEntry = _misc ? (_misc->RangeIndex ? sSpellRangeStore.LookupEntry(_misc->RangeIndex) : nullptr) : nullptr;
- Speed = _misc ? _misc->Speed : 0;
- LaunchDelay = _misc ? _misc->LaunchDelay : 0;
- SchoolMask = _misc ? _misc->SchoolMask : 0;
- AttributesCu = 0;
- IconFileDataId = _misc ? _misc->SpellIconFileDataID : 0;
- ActiveIconFileDataId = _misc ? _misc->ActiveIconFileDataID : 0;
- ContentTuningId = _misc ? _misc->ContentTuningID : 0;
- ShowFutureSpellPlayerConditionID = _misc ? _misc->ShowFutureSpellPlayerConditionID : 0;
+ if (SpellMiscEntry const* _misc = data.Misc)
+ {
+ Attributes = _misc->Attributes[0];
+ AttributesEx = _misc->Attributes[1];
+ AttributesEx2 = _misc->Attributes[2];
+ AttributesEx3 = _misc->Attributes[3];
+ AttributesEx4 = _misc->Attributes[4];
+ AttributesEx5 = _misc->Attributes[5];
+ AttributesEx6 = _misc->Attributes[6];
+ AttributesEx7 = _misc->Attributes[7];
+ AttributesEx8 = _misc->Attributes[8];
+ AttributesEx9 = _misc->Attributes[9];
+ AttributesEx10 = _misc->Attributes[10];
+ AttributesEx11 = _misc->Attributes[11];
+ AttributesEx12 = _misc->Attributes[12];
+ AttributesEx13 = _misc->Attributes[13];
+ AttributesEx14 = _misc->Attributes[14];
+ CastTimeEntry = sSpellCastTimesStore.LookupEntry(_misc->CastingTimeIndex);
+ DurationEntry = sSpellDurationStore.LookupEntry(_misc->DurationIndex);
+ RangeEntry = sSpellRangeStore.LookupEntry(_misc->RangeIndex);
+ Speed = _misc->Speed;
+ LaunchDelay = _misc->LaunchDelay;
+ SchoolMask = _misc->SchoolMask;
+ IconFileDataId = _misc->SpellIconFileDataID;
+ ActiveIconFileDataId = _misc->ActiveIconFileDataID;
+ ContentTuningId = _misc->ContentTuningID;
+ ShowFutureSpellPlayerConditionID = _misc->ShowFutureSpellPlayerConditionID;
+ }
_visuals = std::move(visuals);
// SpellScalingEntry
- SpellScalingEntry const* _scaling = data.Scaling;
- Scaling.Class = _scaling ? _scaling->Class : 0;
- Scaling.MinScalingLevel = _scaling ? _scaling->MinScalingLevel : 0;
- Scaling.MaxScalingLevel = _scaling ? _scaling->MaxScalingLevel : 0;
- Scaling.ScalesFromItemLevel = _scaling ? _scaling->ScalesFromItemLevel : 0;
+ if (SpellScalingEntry const* _scaling = data.Scaling)
+ {
+ Scaling.Class = _scaling->Class;
+ Scaling.MinScalingLevel = _scaling->MinScalingLevel;
+ Scaling.MaxScalingLevel = _scaling->MaxScalingLevel;
+ Scaling.ScalesFromItemLevel = _scaling->ScalesFromItemLevel;
+ }
// SpellAuraOptionsEntry
- SpellAuraOptionsEntry const* _options = data.AuraOptions;
- SpellProcsPerMinuteEntry const* _ppm = _options ? sSpellProcsPerMinuteStore.LookupEntry(_options->SpellProcsPerMinuteID) : nullptr;
- ProcFlags = _options ? _options->ProcTypeMask[0] : 0;
- ProcChance = _options ? _options->ProcChance : 0;
- ProcCharges = _options ? _options->ProcCharges : 0;
- ProcCooldown = _options ? _options->ProcCategoryRecovery : 0;
- ProcBasePPM = _ppm ? _ppm->BaseProcRate : 0.0f;
- if (_options)
- ProcPPMMods = sDB2Manager.GetSpellProcsPerMinuteMods(_options->SpellProcsPerMinuteID);
- StackAmount = _options ? _options->CumulativeAura : 0;
+ if (SpellAuraOptionsEntry const* _options = data.AuraOptions)
+ {
+ ProcFlags = _options->ProcTypeMask[0];
+ ProcChance = _options->ProcChance;
+ ProcCharges = _options->ProcCharges;
+ ProcCooldown = _options->ProcCategoryRecovery;
+ StackAmount = _options->CumulativeAura;
+ if (SpellProcsPerMinuteEntry const* _ppm = sSpellProcsPerMinuteStore.LookupEntry(_options->SpellProcsPerMinuteID))
+ {
+ ProcBasePPM = _ppm->BaseProcRate;
+ ProcPPMMods = sDB2Manager.GetSpellProcsPerMinuteMods(_ppm->ID);
+ }
+ }
// SpellAuraRestrictionsEntry
- SpellAuraRestrictionsEntry const* _aura = data.AuraRestrictions;
- CasterAuraState = _aura ? _aura->CasterAuraState : 0;
- TargetAuraState = _aura ? _aura->TargetAuraState : 0;
- ExcludeCasterAuraState = _aura ? _aura->ExcludeCasterAuraState : 0;
- ExcludeTargetAuraState = _aura ? _aura->ExcludeTargetAuraState : 0;
- CasterAuraSpell = _aura ? _aura->CasterAuraSpell : 0;
- TargetAuraSpell = _aura ? _aura->TargetAuraSpell : 0;
- ExcludeCasterAuraSpell = _aura ? _aura->ExcludeCasterAuraSpell : 0;
- ExcludeTargetAuraSpell = _aura ? _aura->ExcludeTargetAuraSpell : 0;
+ if (SpellAuraRestrictionsEntry const* _aura = data.AuraRestrictions)
+ {
+ CasterAuraState = _aura->CasterAuraState;
+ TargetAuraState = _aura->TargetAuraState;
+ ExcludeCasterAuraState = _aura->ExcludeCasterAuraState;
+ ExcludeTargetAuraState = _aura->ExcludeTargetAuraState;
+ CasterAuraSpell = _aura->CasterAuraSpell;
+ TargetAuraSpell = _aura->TargetAuraSpell;
+ ExcludeCasterAuraSpell = _aura->ExcludeCasterAuraSpell;
+ ExcludeTargetAuraSpell = _aura->ExcludeTargetAuraSpell;
+ }
// SpellCastingRequirementsEntry
- SpellCastingRequirementsEntry const* _castreq = data.CastingRequirements;
- RequiresSpellFocus = _castreq ? _castreq->RequiresSpellFocus : 0;
- FacingCasterFlags = _castreq ? _castreq->FacingCasterFlags : 0;
- RequiredAreasID = _castreq ? _castreq->RequiredAreasID : -1;
+ if (SpellCastingRequirementsEntry const* _castreq = data.CastingRequirements)
+ {
+ RequiresSpellFocus = _castreq->RequiresSpellFocus;
+ FacingCasterFlags = _castreq->FacingCasterFlags;
+ RequiredAreasID = _castreq->RequiredAreasID;
+ }
// SpellCategoriesEntry
- SpellCategoriesEntry const* _categorie = data.Categories;
- CategoryId = _categorie ? _categorie->Category : 0;
- Dispel = _categorie ? _categorie->DispelType : 0;
- Mechanic = _categorie ? _categorie->Mechanic : 0;
- StartRecoveryCategory = _categorie ? _categorie->StartRecoveryCategory : 0;
- DmgClass = _categorie ? _categorie->DefenseType : 0;
- PreventionType = _categorie ? _categorie->PreventionType : 0;
- ChargeCategoryId = _categorie ? _categorie->ChargeCategory : 0;
+ if (SpellCategoriesEntry const* _categories = data.Categories)
+ {
+ CategoryId = _categories->Category;
+ Dispel = _categories->DispelType;
+ Mechanic = _categories->Mechanic;
+ StartRecoveryCategory = _categories->StartRecoveryCategory;
+ DmgClass = _categories->DefenseType;
+ PreventionType = _categories->PreventionType;
+ ChargeCategoryId = _categories->ChargeCategory;
+ }
// SpellClassOptionsEntry
- SpellClassOptionsEntry const* _class = data.ClassOptions;
- SpellFamilyName = _class ? _class->SpellClassSet : 0;
- SpellFamilyFlags = _class ? _class->SpellClassMask : flag128();
+ if (SpellClassOptionsEntry const* _class = data.ClassOptions)
+ {
+ SpellFamilyName = _class->SpellClassSet;
+ SpellFamilyFlags = _class->SpellClassMask;
+ }
// SpellCooldownsEntry
- SpellCooldownsEntry const* _cooldowns = data.Cooldowns;
- RecoveryTime = _cooldowns ? _cooldowns->RecoveryTime : 0;
- CategoryRecoveryTime = _cooldowns ? _cooldowns->CategoryRecoveryTime : 0;
- StartRecoveryTime = _cooldowns ? _cooldowns->StartRecoveryTime : 0;
+ if (SpellCooldownsEntry const* _cooldowns = data.Cooldowns)
+ {
+ RecoveryTime = _cooldowns->RecoveryTime;
+ CategoryRecoveryTime = _cooldowns->CategoryRecoveryTime;
+ StartRecoveryTime = _cooldowns->StartRecoveryTime;
+ }
// SpellEquippedItemsEntry
- SpellEquippedItemsEntry const* _equipped = data.EquippedItems;
- EquippedItemClass = _equipped ? _equipped->EquippedItemClass : -1;
- EquippedItemSubClassMask = _equipped ?_equipped->EquippedItemSubclass : 0;
- EquippedItemInventoryTypeMask = _equipped ? _equipped->EquippedItemInvTypes : 0;
+ if (SpellEquippedItemsEntry const* _equipped = data.EquippedItems)
+ {
+ EquippedItemClass = _equipped->EquippedItemClass;
+ EquippedItemSubClassMask = _equipped->EquippedItemSubclass;
+ EquippedItemInventoryTypeMask = _equipped->EquippedItemInvTypes;
+ }
// SpellInterruptsEntry
if (SpellInterruptsEntry const* _interrupt = data.Interrupts)
@@ -1202,57 +1216,65 @@ SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, S
std::copy(std::begin(_interrupt->AuraInterruptFlags), std::end(_interrupt->AuraInterruptFlags), AuraInterruptFlags.begin());
std::copy(std::begin(_interrupt->ChannelInterruptFlags), std::end(_interrupt->ChannelInterruptFlags), ChannelInterruptFlags.begin());
}
- else
- {
- InterruptFlags = 0;
- AuraInterruptFlags.fill(0);
- ChannelInterruptFlags.fill(0);
- }
// SpellLevelsEntry
- SpellLevelsEntry const* _levels = data.Levels;
- MaxLevel = _levels ? _levels->MaxLevel : 0;
- BaseLevel = _levels ? _levels->BaseLevel : 0;
- SpellLevel = _levels ? _levels->SpellLevel : 0;
+ if (SpellLevelsEntry const* _levels = data.Levels)
+ {
+ MaxLevel = _levels->MaxLevel;
+ BaseLevel = _levels->BaseLevel;
+ SpellLevel = _levels->SpellLevel;
+ }
// SpellPowerEntry
PowerCosts = data.Powers;
// SpellReagentsEntry
- SpellReagentsEntry const* _reagents = data.Reagents;
- for (uint8 i = 0; i < MAX_SPELL_REAGENTS; ++i)
- Reagent[i] = _reagents ? _reagents->Reagent[i] : 0;
- for (uint8 i = 0; i < MAX_SPELL_REAGENTS; ++i)
- ReagentCount[i] = _reagents ? _reagents->ReagentCount[i] : 0;
+ 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());
+ }
// SpellShapeshiftEntry
- SpellShapeshiftEntry const* _shapeshift = data.Shapeshift;
- Stances = _shapeshift ? MAKE_PAIR64(_shapeshift->ShapeshiftMask[0], _shapeshift->ShapeshiftMask[1]) : 0;
- StancesNot = _shapeshift ? MAKE_PAIR64(_shapeshift->ShapeshiftExclude[0], _shapeshift->ShapeshiftExclude[1]) : 0;
+ if (SpellShapeshiftEntry const* _shapeshift = data.Shapeshift)
+ {
+ Stances = MAKE_PAIR64(_shapeshift->ShapeshiftMask[0], _shapeshift->ShapeshiftMask[1]);
+ StancesNot = MAKE_PAIR64(_shapeshift->ShapeshiftExclude[0], _shapeshift->ShapeshiftExclude[1]);
+ }
// SpellTargetRestrictionsEntry
- SpellTargetRestrictionsEntry const* _target = data.TargetRestrictions;
- ConeAngle = _target ? _target->ConeDegrees : 0.f;
- Width = _target ? _target->Width : 0.f;
- Targets = _target ? _target->Targets : 0;
- TargetCreatureType = _target ? _target->TargetCreatureType : 0;
- MaxAffectedTargets = _target ? _target->MaxTargets : 0;
- MaxTargetLevel = _target ? _target->MaxTargetLevel : 0;
+ if (SpellTargetRestrictionsEntry const* _target = data.TargetRestrictions)
+ {
+ ConeAngle = _target->ConeDegrees;
+ Width = _target->Width;
+ Targets = _target->Targets;
+ TargetCreatureType = _target->TargetCreatureType;
+ MaxAffectedTargets = _target->MaxTargets;
+ MaxTargetLevel = _target->MaxTargetLevel;
+ }
// SpellTotemsEntry
- SpellTotemsEntry const* _totem = data.Totems;
- for (uint8 i = 0; i < 2; ++i)
- TotemCategory[i] = _totem ? _totem->RequiredTotemCategoryID[i] : 0;
- for (uint8 i = 0; i < 2; ++i)
- Totem[i] = _totem ? _totem->Totem[i] : 0;
+ 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());
+ }
+}
- ChainEntry = nullptr;
- ExplicitTargetMask = 0;
+SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, std::vector<SpellEffectEntry> const& effects)
+ : Id(spellName->ID), Difficulty(difficulty)
+{
+ SpellName = &spellName->Name;
- _spellSpecific = SPELL_SPECIFIC_NORMAL;
- _auraState = AURA_STATE_NONE;
+ _effects.reserve(32);
+ for (SpellEffectEntry const& spellEffect : effects)
+ {
+ if (uint32(spellEffect.EffectIndex) >= _effects.size())
+ _effects.resize(spellEffect.EffectIndex + 1);
- _allowedMechanicMask = 0;
+ _effects[spellEffect.EffectIndex] = new SpellEffectInfo(this, spellEffect);
+ }
+ _effects.shrink_to_fit();
}
SpellInfo::~SpellInfo()