- [X] Converts targeting packets. ### BREAKING CHANGE TO TARGET CLASS ```cs public virtual Packet GetPacketFor(NetState ns) ``` Changed to: ```cs public virtual void SendPacketTo(NetState ns) ``` Bumps release version
87 lines
2.9 KiB
C#
87 lines
2.9 KiB
C#
/*************************************************************************
|
|
* ModernUO *
|
|
* Copyright 2019-2020 - ModernUO Development Team *
|
|
* Email: hi@modernuo.com *
|
|
* File: OutgoingTargetPackets.cs *
|
|
* *
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation, either version 3 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
|
*************************************************************************/
|
|
|
|
using System;
|
|
using System.Buffers;
|
|
using Server.Targeting;
|
|
|
|
namespace Server.Network
|
|
{
|
|
public static class OutgoingTargetPackets
|
|
{
|
|
public static void SendMultiTargetReq(this NetState ns, MultiTarget t)
|
|
{
|
|
if (ns == null || !ns.GetSendBuffer(out var buffer))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var writer = new CircularBufferWriter(buffer);
|
|
writer.Write((byte)0x99); // Packet ID
|
|
writer.Write(t.AllowGround);
|
|
writer.Write(t.TargetID);
|
|
writer.Write((byte)t.Flags);
|
|
writer.Clear(11);
|
|
writer.Write((short)t.MultiID);
|
|
writer.Write((short)t.Offset.X);
|
|
writer.Write((short)t.Offset.Y);
|
|
writer.Write((short)t.Offset.Z);
|
|
if (ns.HighSeas)
|
|
{
|
|
writer.Write(0);
|
|
}
|
|
|
|
ns.Send(ref buffer, writer.Position);
|
|
}
|
|
|
|
public static void SendCancelTarget(this NetState ns)
|
|
{
|
|
if (ns == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Span<byte> span = stackalloc byte[]
|
|
{
|
|
0x6C, // Packet ID
|
|
0, // Allow Ground?
|
|
0, 0, 0, 0, // Target ID
|
|
3, // Flags
|
|
0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0,
|
|
0, 0
|
|
};
|
|
|
|
ns.Send(span);
|
|
}
|
|
|
|
public static void SendTargetReq(this NetState ns, Target t)
|
|
{
|
|
if (ns == null || !ns.GetSendBuffer(out var buffer))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var writer = new CircularBufferWriter(buffer);
|
|
writer.Write((byte)0x6C); // Packet ID
|
|
writer.Write(t.AllowGround);
|
|
writer.Write(t.TargetID);
|
|
writer.Write((byte)t.Flags);
|
|
writer.Clear(12);
|
|
|
|
ns.Send(ref buffer, writer.Position);
|
|
}
|
|
}
|
|
}
|