Remove custom OptionalType and use the default c# nullable type.

This commit is contained in:
hondacrx
2022-03-01 17:27:56 -05:00
parent cc08afe269
commit c14f1eb3dc
89 changed files with 924 additions and 976 deletions
+5 -5
View File
@@ -237,11 +237,11 @@ namespace Game.Spells
if (remove)
return;
auraInfo.AuraData.Value = new();
auraInfo.AuraData = new();
Aura aura = GetBase();
AuraDataInfo auraData = auraInfo.AuraData.Value;
AuraDataInfo auraData = auraInfo.AuraData;
auraData.CastID = aura.GetCastId();
auraData.SpellID = (int)aura.GetId();
auraData.Visual = aura.GetSpellVisual();
@@ -261,12 +261,12 @@ namespace Game.Spells
if (!aura.GetCasterGUID().IsUnit())
auraData.CastUnit = ObjectGuid.Empty; // optional data is filled in, but cast unit contains empty guid in packet
else if (!auraData.Flags.HasFlag(AuraFlags.NoCaster))
auraData.CastUnit.Set(aura.GetCasterGUID());
auraData.CastUnit = aura.GetCasterGUID();
if (auraData.Flags.HasFlag(AuraFlags.Duration))
{
auraData.Duration.Set(aura.GetMaxDuration());
auraData.Remaining.Set(aura.GetDuration());
auraData.Duration = aura.GetMaxDuration();
auraData.Remaining = aura.GetDuration();
}
if (auraData.Flags.HasFlag(AuraFlags.Scalable))
+11 -9
View File
@@ -3666,9 +3666,9 @@ namespace Game.Spells
if (castFlags.HasAnyFlag(SpellCastFlags.RuneList)) // rune cooldowns list
{
castData.RemainingRunes.Value = new();
castData.RemainingRunes = new();
RuneData runeData = castData.RemainingRunes.Value;
RuneData runeData = castData.RemainingRunes;
//TODO: There is a crash caused by a spell with CAST_FLAG_RUNE_LIST casted by a creature
//The creature is the mover of a player, so HandleCastSpellOpcode uses it as the caster
@@ -3781,8 +3781,8 @@ namespace Game.Spells
if (Convert.ToBoolean(castFlags & SpellCastFlags.RuneList)) // rune cooldowns list
{
castData.RemainingRunes.Value = new();
RuneData runeData = castData.RemainingRunes.Value;
castData.RemainingRunes = new();
RuneData runeData = castData.RemainingRunes;
Player player = m_caster.ToPlayer();
runeData.Start = m_runesState; // runes state before
@@ -4095,9 +4095,11 @@ namespace Game.Spells
if (schoolImmunityMask != 0 || mechanicImmunityMask != 0)
{
spellChannelStart.InterruptImmunities.Value = new();
spellChannelStart.InterruptImmunities.Value.SchoolImmunities = (int)schoolImmunityMask;
spellChannelStart.InterruptImmunities.Value.Immunities = (int)mechanicImmunityMask;
SpellChannelStartInterruptImmunities interruptImmunities = new();
interruptImmunities.SchoolImmunities = (int)schoolImmunityMask;
interruptImmunities.Immunities = (int)mechanicImmunityMask;
spellChannelStart.InterruptImmunities = interruptImmunities;
}
unitCaster.SendMessageToSet(spellChannelStart, true);
@@ -7177,7 +7179,7 @@ namespace Game.Spells
m_spellValue.DurationMul = (float)value / 100.0f;
break;
case SpellValueMod.Duration:
m_spellValue.Duration.Set(value);
m_spellValue.Duration = value;
break;
}
}
@@ -8439,7 +8441,7 @@ namespace Game.Spells
public int AuraStackAmount;
public float DurationMul;
public float CriticalChance;
public Optional<int> Duration;
public int? Duration;
}
// Spell modifier (used for modify other spells)
+2 -4
View File
@@ -88,7 +88,6 @@ namespace Game.Spells
if (m_targetMask.HasAnyFlag(SpellCastTargetFlags.SourceLocation))
{
data.SrcLocation.Value = new();
TargetLocation target = new();
target.Transport = m_src.TransportGUID; // relative position guid here - transport for example
if (!m_src.TransportGUID.IsEmpty())
@@ -96,12 +95,11 @@ namespace Game.Spells
else
target.Location = m_src.Position;
data.SrcLocation.Value = target;
data.SrcLocation = target;
}
if (Convert.ToBoolean(m_targetMask & SpellCastTargetFlags.DestLocation))
{
data.DstLocation.Value = new();
TargetLocation target = new();
target.Transport = m_dst.TransportGUID; // relative position guid here - transport for example
if (!m_dst.TransportGUID.IsEmpty())
@@ -109,7 +107,7 @@ namespace Game.Spells
else
target.Location = m_dst.Position;
data.DstLocation.Value = target;
data.DstLocation = target;
}
if (Convert.ToBoolean(m_targetMask & SpellCastTargetFlags.String))
+9 -9
View File
@@ -5587,28 +5587,28 @@ namespace Game.Spells
if (jumpParams.TreatSpeedAsMoveTimeSeconds)
speed = unitCaster.GetExactDist(destTarget) / jumpParams.Speed;
Optional<JumpArrivalCastArgs> arrivalCast = new();
JumpArrivalCastArgs arrivalCast = null;
if (effectInfo.TriggerSpell != 0)
{
arrivalCast.Value = new();
arrivalCast.Value.SpellId = effectInfo.TriggerSpell;
arrivalCast = new();
arrivalCast.SpellId = effectInfo.TriggerSpell;
}
Optional<SpellEffectExtraData> effectExtra = new();
SpellEffectExtraData effectExtra = null;
if (jumpParams.SpellVisualId.HasValue || jumpParams.ProgressCurveId.HasValue || jumpParams.ParabolicCurveId.HasValue)
{
effectExtra.Value = new();
effectExtra = new();
if (jumpParams.SpellVisualId.HasValue)
effectExtra.Value.SpellVisualId = jumpParams.SpellVisualId.Value;
effectExtra.SpellVisualId = jumpParams.SpellVisualId.Value;
if (jumpParams.ProgressCurveId.HasValue)
effectExtra.Value.ProgressCurveId = jumpParams.ProgressCurveId.Value;
effectExtra.ProgressCurveId = jumpParams.ProgressCurveId.Value;
if (jumpParams.ParabolicCurveId.HasValue)
effectExtra.Value.ParabolicCurveId = jumpParams.ParabolicCurveId.Value;
effectExtra.ParabolicCurveId = jumpParams.ParabolicCurveId.Value;
}
unitCaster.GetMotionMaster().MoveJumpWithGravity(destTarget, speed, jumpParams.JumpGravity, EventId.Jump, false, arrivalCast.Value, effectExtra.Value);
unitCaster.GetMotionMaster().MoveJumpWithGravity(destTarget, speed, jumpParams.JumpGravity, EventId.Jump, false, arrivalCast, effectExtra);
}
[SpellEffectHandler(SpellEffectName.LearnTransmogSet)]