Fixed a crash

This commit is contained in:
hondacrx
2022-08-01 11:31:56 -04:00
parent 3d1c0384f0
commit bd3dfeb637
2 changed files with 19 additions and 19 deletions
+13 -13
View File
@@ -1491,7 +1491,7 @@ namespace Game.Networking.Packets
public AuraDataInfo AuraData; public AuraDataInfo AuraData;
} }
public struct TargetLocation public class TargetLocation
{ {
public ObjectGuid Transport; public ObjectGuid Transport;
public Position Location; public Position Location;
@@ -1533,11 +1533,11 @@ namespace Game.Networking.Packets
Unit = data.ReadPackedGuid(); Unit = data.ReadPackedGuid();
Item = data.ReadPackedGuid(); Item = data.ReadPackedGuid();
if (SrcLocation.HasValue) if (SrcLocation != null)
SrcLocation.Value.Read(data); SrcLocation.Read(data);
if (DstLocation.HasValue) if (DstLocation != null)
DstLocation.Value.Read(data); DstLocation.Read(data);
if (hasOrientation) if (hasOrientation)
Orientation = data.ReadFloat(); Orientation = data.ReadFloat();
@@ -1551,8 +1551,8 @@ namespace Game.Networking.Packets
public void Write(WorldPacket data) public void Write(WorldPacket data)
{ {
data.WriteBits((uint)Flags, 26); data.WriteBits((uint)Flags, 26);
data.WriteBit(SrcLocation.HasValue); data.WriteBit(SrcLocation != null);
data.WriteBit(DstLocation.HasValue); data.WriteBit(DstLocation != null);
data.WriteBit(Orientation.HasValue); data.WriteBit(Orientation.HasValue);
data.WriteBit(MapID.HasValue); data.WriteBit(MapID.HasValue);
data.WriteBits(Name.GetByteCount(), 7); data.WriteBits(Name.GetByteCount(), 7);
@@ -1561,11 +1561,11 @@ namespace Game.Networking.Packets
data.WritePackedGuid(Unit); data.WritePackedGuid(Unit);
data.WritePackedGuid(Item); data.WritePackedGuid(Item);
if (SrcLocation.HasValue) if (SrcLocation != null)
SrcLocation.Value.Write(data); SrcLocation.Write(data);
if (DstLocation.HasValue) if (DstLocation != null)
DstLocation.Value.Write(data); DstLocation.Write(data);
if (Orientation.HasValue) if (Orientation.HasValue)
data.WriteFloat(Orientation.Value); data.WriteFloat(Orientation.Value);
@@ -1579,8 +1579,8 @@ namespace Game.Networking.Packets
public SpellCastTargetFlags Flags; public SpellCastTargetFlags Flags;
public ObjectGuid Unit; public ObjectGuid Unit;
public ObjectGuid Item; public ObjectGuid Item;
public TargetLocation? SrcLocation; public TargetLocation SrcLocation;
public TargetLocation? DstLocation; public TargetLocation DstLocation;
public float? Orientation; public float? Orientation;
public int? MapID; public int? MapID;
public string Name = ""; public string Name = "";
+6 -6
View File
@@ -42,30 +42,30 @@ namespace Game.Spells
m_src = new SpellDestination(); m_src = new SpellDestination();
m_dst = new SpellDestination(); m_dst = new SpellDestination();
if (spellCastRequest.Target.SrcLocation.HasValue) if (spellCastRequest.Target.SrcLocation != null)
{ {
m_src.TransportGUID = spellCastRequest.Target.SrcLocation.Value.Transport; m_src.TransportGUID = spellCastRequest.Target.SrcLocation.Transport;
Position pos; Position pos;
if (!m_src.TransportGUID.IsEmpty()) if (!m_src.TransportGUID.IsEmpty())
pos = m_src.TransportOffset; pos = m_src.TransportOffset;
else else
pos = m_src.Position; pos = m_src.Position;
pos.Relocate(spellCastRequest.Target.SrcLocation.Value.Location); pos.Relocate(spellCastRequest.Target.SrcLocation.Location);
if (spellCastRequest.Target.Orientation.HasValue) if (spellCastRequest.Target.Orientation.HasValue)
pos.SetOrientation(spellCastRequest.Target.Orientation.Value); pos.SetOrientation(spellCastRequest.Target.Orientation.Value);
} }
if (spellCastRequest.Target.DstLocation.HasValue) if (spellCastRequest.Target.DstLocation != null)
{ {
m_dst.TransportGUID = spellCastRequest.Target.DstLocation.Value.Transport; m_dst.TransportGUID = spellCastRequest.Target.DstLocation.Transport;
Position pos; Position pos;
if (!m_dst.TransportGUID.IsEmpty()) if (!m_dst.TransportGUID.IsEmpty())
pos = m_dst.TransportOffset; pos = m_dst.TransportOffset;
else else
pos = m_dst.Position; pos = m_dst.Position;
pos.Relocate(spellCastRequest.Target.DstLocation.Value.Location); pos.Relocate(spellCastRequest.Target.DstLocation.Location);
if (spellCastRequest.Target.Orientation.HasValue) if (spellCastRequest.Target.Orientation.HasValue)
pos.SetOrientation(spellCastRequest.Target.Orientation.Value); pos.SetOrientation(spellCastRequest.Target.Orientation.Value);
} }