Some misc cleansup.

This commit is contained in:
hondacrx
2023-10-06 17:33:20 -04:00
parent 85f37f6edf
commit ccb5341c21
13 changed files with 30 additions and 42 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ namespace Game.AI
if (me.GetVictim() && me.GetVictim().IsAlive())
{
// is only necessary to stop casting, the pet must not exit combat
if (!me.GetCurrentSpell(CurrentSpellTypes.Channeled) && // ignore channeled spells (Pin, Seduction)
if (me.GetCurrentSpell(CurrentSpellTypes.Channeled) == null && // ignore channeled spells (Pin, Seduction)
(me.GetVictim() && me.GetVictim().HasBreakableByDamageCrowdControlAura(me)))
{
me.InterruptNonMeleeSpells(false);
+3 -3
View File
@@ -3178,7 +3178,7 @@ namespace Game.Entities
return false;
}
if (focusSpell)
if (focusSpell != null)
return focusSpell == _spellFocusInfo.Spell;
else
return _spellFocusInfo.Spell != null || _spellFocusInfo.Delay != 0;
@@ -3186,11 +3186,11 @@ namespace Game.Entities
public void ReleaseSpellFocus(Spell focusSpell = null, bool withDelay = true)
{
if (!_spellFocusInfo.Spell)
if (_spellFocusInfo.Spell == null)
return;
// focused to something else
if (focusSpell && focusSpell != _spellFocusInfo.Spell)
if (focusSpell != null && focusSpell != _spellFocusInfo.Spell)
return;
if (_spellFocusInfo.Spell.GetSpellInfo().HasAttribute(SpellAttr5.AiDoesntFaceTarget))
+1 -1
View File
@@ -2453,7 +2453,7 @@ namespace Game.Entities
if (spell.m_CastItem == null && info.HasAttribute(SpellAttr2.RetainItemCast))
{
if (args.TriggeringSpell)
if (args.TriggeringSpell != null)
spell.m_CastItem = args.TriggeringSpell.m_CastItem;
else if (args.TriggeringAura != null && !args.TriggeringAura.GetBase().GetCastItemGUID().IsEmpty())
{
+3 -3
View File
@@ -1000,7 +1000,7 @@ namespace Game.Entities
return;
// Call not from spell cast, send cooldown event for item spells if no in combat
if (!spell)
if (spell == null)
{
// spell/item pair let set proper cooldown (except not existed charged spell cooldown spellmods for potions)
ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(m_lastPotionId);
@@ -2946,7 +2946,7 @@ namespace Game.Entities
pct = 1.0f;
// Drop charges for triggering spells instead of triggered ones
if (m_spellModTakingSpell)
if (m_spellModTakingSpell != null)
spell = m_spellModTakingSpell;
switch (op)
@@ -3114,7 +3114,7 @@ namespace Game.Entities
return false;
// First time this aura applies a mod to us and is out of charges
if (spell && mod.ownerAura.IsUsingCharges() && mod.ownerAura.GetCharges() == 0 && !spell.m_appliedMods.Contains(mod.ownerAura))
if (spell != null && mod.ownerAura.IsUsingCharges() && mod.ownerAura.GetCharges() == 0 && !spell.m_appliedMods.Contains(mod.ownerAura))
return false;
switch (mod.op)
+2 -2
View File
@@ -198,7 +198,7 @@ namespace Game.Entities
public SpellInfo GetSpellInfo()
{
if (_spell)
if (_spell != null)
return _spell.GetSpellInfo();
if (_damageInfo != null)
return _damageInfo.GetSpellInfo();
@@ -209,7 +209,7 @@ namespace Game.Entities
}
public SpellSchoolMask GetSchoolMask()
{
if (_spell)
if (_spell != null)
return _spell.GetSpellInfo().GetSchoolMask();
if (_damageInfo != null)
return _damageInfo.GetSchoolMask();
+9 -10
View File
@@ -733,7 +733,7 @@ namespace Game.Entities
}
// call script handlers
if (spell)
if (spell != null)
spell.CallScriptCalcCritChanceHandlers(this, ref crit_chance);
else
aurEff.GetBase().CallScriptEffectCalcCritChanceHandlers(aurEff, aurEff.GetBase().GetApplicationOfTarget(GetGUID()), this, ref crit_chance);
@@ -1620,7 +1620,7 @@ namespace Game.Entities
Player modOwner = GetSpellModOwner();
if (modOwner)
{
if (modOwner != this && spell)
if (modOwner != this && spell != null)
{
List<AuraApplication> modAuras = new();
foreach (var itr in modOwner.GetAppliedAuras())
@@ -1648,7 +1648,7 @@ namespace Game.Entities
void TriggerAurasProcOnEvent(ProcEventInfo eventInfo, List<Tuple<uint, AuraApplication>> aurasTriggeringProc)
{
Spell triggeringSpell = eventInfo.GetProcSpell();
bool disableProcs = triggeringSpell && triggeringSpell.IsProcDisabled();
bool disableProcs = triggeringSpell != null && triggeringSpell.IsProcDisabled();
int oldProcChainLength = m_procChainLength;
@@ -1746,7 +1746,7 @@ namespace Game.Entities
}
case CurrentSpellTypes.AutoRepeat:
{
if (GetCurrentSpell(CSpellType) && GetCurrentSpell(CSpellType).GetState() == SpellState.Idle)
if (GetCurrentSpell(CSpellType) != null && GetCurrentSpell(CSpellType).GetState() == SpellState.Idle)
GetCurrentSpell(CSpellType).SetState(SpellState.Finished);
// only Auto Shoot does not break anything
@@ -1780,9 +1780,7 @@ namespace Game.Entities
// generic spells are cast when they are not finished and not delayed
var currentSpell = GetCurrentSpell(CurrentSpellTypes.Generic);
if (currentSpell &&
(currentSpell.GetState() != SpellState.Finished) &&
(withDelayed || currentSpell.GetState() != SpellState.Delayed))
if (currentSpell != null && (currentSpell.GetState() != SpellState.Finished) && (withDelayed || currentSpell.GetState() != SpellState.Delayed))
{
if (!skipInstant || currentSpell.GetCastTime() != 0)
{
@@ -1790,17 +1788,18 @@ namespace Game.Entities
return true;
}
}
currentSpell = GetCurrentSpell(CurrentSpellTypes.Channeled);
// channeled spells may be delayed, but they are still considered cast
if (!skipChanneled && currentSpell &&
(currentSpell.GetState() != SpellState.Finished))
if (!skipChanneled && currentSpell != null && (currentSpell.GetState() != SpellState.Finished))
{
if (!isAutoshoot || !currentSpell.m_spellInfo.HasAttribute(SpellAttr2.DoNotResetCombatTimers))
return true;
}
currentSpell = GetCurrentSpell(CurrentSpellTypes.AutoRepeat);
// autorepeat spells may be finished or delayed, but they are still considered cast
if (!skipAutorepeat && currentSpell)
if (!skipAutorepeat && currentSpell != null)
return true;
return false;
+1 -1
View File
@@ -672,7 +672,7 @@ namespace Game
{
Unit caster = Global.ObjAccessor.GetUnit(GetPlayer(), packet.Guid);
Spell spell = caster ? caster.GetCurrentSpell(CurrentSpellTypes.Generic) : null;
if (!spell || spell.m_spellInfo.Id != packet.SpellID || spell.m_castId != packet.CastID || !spell.m_targets.HasDst() || !spell.m_targets.HasSrc())
if (spell == null || spell.m_spellInfo.Id != packet.SpellID || spell.m_castId != packet.CastID || !spell.m_targets.HasDst() || !spell.m_targets.HasSrc())
return;
Position pos = spell.m_targets.GetSrcPos();
+2 -2
View File
@@ -476,10 +476,10 @@ namespace Game
trader.ModifyMoney(-(long)his_trade.GetMoney());
trader.ModifyMoney((long)my_trade.GetMoney());
if (my_spell)
if (my_spell != null)
my_spell.Prepare(my_targets);
if (his_spell)
if (his_spell != null)
his_spell.Prepare(his_targets);
// cleanup
-6
View File
@@ -283,12 +283,6 @@ namespace Game.Scripting
public void IncrementScriptCount() { ++_ScriptCount; }
public uint GetScriptCount() { return _ScriptCount; }
//Reloading
public void Reload()
{
}
//Unloading
public void Unload()
{
+1 -1
View File
@@ -1696,7 +1696,7 @@ namespace Game.Spells
// check spell triggering us
Spell spell = eventInfo.GetProcSpell();
if (spell)
if (spell != null)
{
// Do not allow auras to proc from effect triggered from itself
if (spell.IsTriggeredByAura(m_spellInfo))
+3 -3
View File
@@ -637,7 +637,7 @@ namespace Game.Spells
break;
case AuraType.ModCastingSpeedNotStack:
// skip melee hits and instant cast spells
if (!eventInfo.GetProcSpell() || eventInfo.GetProcSpell().GetCastTime() == 0)
if (eventInfo.GetProcSpell() == null || eventInfo.GetProcSpell().GetCastTime() == 0)
return false;
break;
case AuraType.ModSchoolMaskDamageFromCaster:
@@ -651,7 +651,7 @@ namespace Game.Spells
{
// Skip melee hits and spells with wrong school or zero cost
if (spellInfo == null || !Convert.ToBoolean((int)spellInfo.GetSchoolMask() & GetMiscValue()) // School Check
|| !eventInfo.GetProcSpell())
|| eventInfo.GetProcSpell() == null)
return false;
// Costs Check
@@ -1963,7 +1963,7 @@ namespace Game.Spells
for (var i = CurrentSpellTypes.Melee; i < CurrentSpellTypes.Max; ++i)
{
Spell spell = target.GetCurrentSpell(i);
if (spell)
if (spell != null)
if (spell.m_spellInfo.PreventionType.HasAnyFlag(SpellPreventionType.NoActions))
// Stop spells on prepare or casting state
target.InterruptSpell(i, false);
+3 -8
View File
@@ -106,7 +106,7 @@ namespace Game.Spells
for (var i = 0; i < m_loadedScripts.Count; ++i)
m_loadedScripts[i]._Unload();
if (m_referencedFromCurrentSpell && m_selfContainer && m_selfContainer == this)
if (m_referencedFromCurrentSpell && m_selfContainer != null && m_selfContainer == this)
{
// Clean the reference to avoid later crash.
// If this error is repeating, we may have to add an ASSERT to better track down how we get into this case.
@@ -2722,13 +2722,13 @@ namespace Game.Spells
if (modOwner)
{
lastSpellMod = modOwner.m_spellModTakingSpell;
if (lastSpellMod)
if (lastSpellMod != null)
modOwner.SetSpellModTakingSpell(lastSpellMod, false);
}
_cast(skipCheck);
if (lastSpellMod)
if (lastSpellMod != null)
modOwner.SetSpellModTakingSpell(lastSpellMod, true);
}
@@ -8086,11 +8086,6 @@ namespace Game.Spells
public int GetTimer() { return m_timer; }
public static implicit operator bool(Spell spell)
{
return spell != null;
}
#region Fields
Dictionary<SpellEffectName, SpellLogEffect> _executeLogEffects = new();
PathGenerator m_preGeneratedPath;
+1 -1
View File
@@ -468,7 +468,7 @@ namespace Game.Entities
// check power requirement
if (procEntry.AttributesMask.HasAnyFlag(ProcAttributes.ReqPowerCost))
{
if (!eventInfo.GetProcSpell())
if (eventInfo.GetProcSpell() == null)
return false;
var costs = eventInfo.GetProcSpell().GetPowerCost();