Converts Item & Entity Packets (#326)
- [X] Converts World Item packets - [X] Converter Remove Entity packets - [X] Updates `LOSBlocker` and `Blocker` - [X] Fixes a few bugs - [X] Converts container packets Bumps release version
This commit is contained in:
parent
c41906d3c7
commit
77f665502b
26 changed files with 1351 additions and 1606 deletions
73
Projects/Server/Network/Packets/OutgoingEntityPackets.cs
Normal file
73
Projects/Server/Network/Packets/OutgoingEntityPackets.cs
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: OutgoingEntityPackets.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;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public static class OutgoingEntityPackets
|
||||
{
|
||||
public const int OPLPacketLength = 9;
|
||||
public const int RemoveEntityLength = 5;
|
||||
|
||||
public static void CreateOPLInfo(ref Span<byte> buffer, Item item) =>
|
||||
CreateOPLInfo(ref buffer, item.Serial, item.PropertyList.Hash);
|
||||
|
||||
public static void CreateOPLInfo(ref Span<byte> buffer, Serial serial, int hash)
|
||||
{
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0xDC); // Packet ID
|
||||
writer.Write(serial);
|
||||
writer.Write(hash);
|
||||
}
|
||||
|
||||
public static void SendOPLInfo(this NetState ns, IPropertyListObject obj) =>
|
||||
ns.SendOPLInfo(obj.Serial, obj.PropertyList.Hash);
|
||||
|
||||
public static void SendOPLInfo(this NetState ns, Serial serial, int hash)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OPLPacketLength];
|
||||
CreateOPLInfo(ref buffer, serial, hash);
|
||||
|
||||
ns.Send(buffer);
|
||||
}
|
||||
|
||||
public static void CreateRemoveEntity(ref Span<byte> buffer, Serial serial)
|
||||
{
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0x1D); // Packet ID
|
||||
writer.Write(serial);
|
||||
}
|
||||
|
||||
public static void SendRemoveEntity(this NetState ns, Serial serial)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Span<byte> buffer = stackalloc byte[RemoveEntityLength];
|
||||
CreateRemoveEntity(ref buffer, serial);
|
||||
|
||||
ns.Send(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue