Core/Spells: Replace MAX_SPELL_EFFECTS loop limits with correct upper bound depending on how many effects the spell has
Port From (https://github.com/TrinityCore/TrinityCore/commit/561b122364525deaee815ad900a78f1323c37776)
This commit is contained in:
@@ -2241,8 +2241,10 @@ namespace Game.Entities
|
||||
|
||||
RemoveOwnedAura(spellId, GetGUID());
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
|
||||
|
||||
// remove pet auras
|
||||
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
for (byte i = 0; i < spellInfo.GetEffects().Count; ++i)
|
||||
{
|
||||
PetAura petSpell = Global.SpellMgr.GetPetAura(spellId, i);
|
||||
if (petSpell != null)
|
||||
@@ -2250,8 +2252,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
// update free primary prof.points (if not overflow setting, can be in case GM use before .learn prof. learning)
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, Difficulty.None);
|
||||
if (spellInfo != null && spellInfo.IsPrimaryProfessionFirstRank())
|
||||
if (spellInfo.IsPrimaryProfessionFirstRank())
|
||||
{
|
||||
uint freeProfs = GetFreePrimaryProfessionPoints() + 1;
|
||||
if (freeProfs <= WorldConfig.GetIntValue(WorldCfg.MaxPrimaryTradeSkill))
|
||||
|
||||
@@ -112,7 +112,7 @@ namespace Game.Scripting
|
||||
uint mask = 0;
|
||||
if (_effIndex == SpellConst.EffectAll || _effIndex == SpellConst.EffectFirstFound)
|
||||
{
|
||||
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
for (byte i = 0; i < spellInfo.GetEffects().Count; ++i)
|
||||
{
|
||||
if (_effIndex == SpellConst.EffectFirstFound && mask != 0)
|
||||
return mask;
|
||||
|
||||
@@ -826,12 +826,9 @@ namespace Game.Spells
|
||||
m_timeCla = 1 * Time.InMilliseconds;
|
||||
|
||||
// also reset periodic counters
|
||||
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
{
|
||||
AuraEffect aurEff = GetEffect(i);
|
||||
foreach (AuraEffect aurEff in GetAuraEffects())
|
||||
if (aurEff != null)
|
||||
aurEff.ResetTicks();
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshTimers(bool resetPeriodicTimer)
|
||||
@@ -851,12 +848,8 @@ namespace Game.Spells
|
||||
RefreshDuration();
|
||||
|
||||
Unit caster = GetCaster();
|
||||
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
{
|
||||
AuraEffect aurEff = GetEffect(i);
|
||||
if (aurEff != null)
|
||||
aurEff.CalculatePeriodic(caster, resetPeriodicTimer, false);
|
||||
}
|
||||
foreach (AuraEffect aurEff in GetAuraEffects())
|
||||
aurEff.CalculatePeriodic(caster, resetPeriodicTimer, false);
|
||||
}
|
||||
|
||||
public void SetCharges(int charges)
|
||||
@@ -1807,10 +1800,10 @@ namespace Game.Spells
|
||||
|
||||
// At least one effect has to pass checks to proc aura
|
||||
uint procEffectMask = aurApp.GetEffectMask();
|
||||
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
if ((procEffectMask & (1u << i)) != 0)
|
||||
if ((procEntry.DisableEffectsMask & (1u << i)) != 0 || !GetEffect(i).CheckEffectProc(aurApp, eventInfo))
|
||||
procEffectMask &= ~(1u << i);
|
||||
foreach (AuraEffect aurEff in GetAuraEffects())
|
||||
if ((procEffectMask & (1u << (int)aurEff.GetEffIndex())) != 0)
|
||||
if ((procEntry.DisableEffectsMask & (1u << (int)aurEff.GetEffIndex())) != 0 || !GetEffect(aurEff.GetEffIndex()).CheckEffectProc(aurApp, eventInfo))
|
||||
procEffectMask &= ~(1u << (int)aurEff.GetEffIndex());
|
||||
|
||||
if (procEffectMask == 0)
|
||||
return 0;
|
||||
|
||||
@@ -5167,7 +5167,7 @@ namespace Game.Spells
|
||||
{
|
||||
CastSpellExtraArgs args = new(this);
|
||||
args.SetTriggerFlags(TriggerCastFlags.FullMask & ~(TriggerCastFlags.IgnorePowerCost | TriggerCastFlags.IgnoreReagentCost));
|
||||
for (int i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
for (int i = 0; i < triggeredSpellInfo.GetEffects().Count; ++i)
|
||||
args.AddSpellMod(SpellValueMod.BasePoint0 + i, GetAmount());
|
||||
|
||||
triggerCaster.CastSpell(target, triggerSpellId, args);
|
||||
|
||||
@@ -313,7 +313,8 @@ namespace Game.Spells
|
||||
args.SetOriginalCaster(originalCaster);
|
||||
args.OriginalCastId = originalCastId;
|
||||
args.OriginalCastItemLevel = itemLevel;
|
||||
if (!castItemGuid.IsEmpty() && Global.SpellMgr.GetSpellInfo(triggerSpell, caster.GetMap().GetDifficultyID()).HasAttribute(SpellAttr2.RetainItemCast))
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(triggerSpell, caster.GetMap().GetDifficultyID());
|
||||
if (!castItemGuid.IsEmpty() && spellInfo.HasAttribute(SpellAttr2.RetainItemCast))
|
||||
{
|
||||
Player triggeringAuraCaster = caster?.ToPlayer();
|
||||
if (triggeringAuraCaster != null)
|
||||
@@ -322,7 +323,7 @@ namespace Game.Spells
|
||||
|
||||
// set basepoints for trigger with value effect
|
||||
if (effect == SpellEffectName.TriggerSpellWithValue)
|
||||
for (int i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
for (int i = 0; i < spellInfo.GetEffects().Count; ++i)
|
||||
args.AddSpellMod(SpellValueMod.BasePoint0 + i, value);
|
||||
|
||||
if (targetCount.HasValue)
|
||||
@@ -395,7 +396,7 @@ namespace Game.Spells
|
||||
args.SetCustomArg(m_customArg);
|
||||
// set basepoints for trigger with value effect
|
||||
if (effectInfo.Effect == SpellEffectName.TriggerMissileSpellWithValue)
|
||||
for (int i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
for (int i = 0; i < spellInfo.GetEffects().Count; ++i)
|
||||
args.AddSpellMod(SpellValueMod.BasePoint0 + i, damage);
|
||||
|
||||
if (targetCount.HasValue)
|
||||
@@ -468,7 +469,7 @@ namespace Game.Spells
|
||||
args.SetTriggeringSpell(this);
|
||||
// set basepoints for trigger with value effect
|
||||
if (effectInfo.Effect == SpellEffectName.ForceCastWithValue)
|
||||
for (int i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
for (int i = 0; i < spellInfo.GetEffects().Count; ++i)
|
||||
args.AddSpellMod(SpellValueMod.BasePoint0 + i, damage);
|
||||
|
||||
unitTarget.CastSpell(m_caster, spellInfo.Id, args);
|
||||
|
||||
Reference in New Issue
Block a user