* Add mapping editor (#757) * Remove mapping actions, never again * Cleanup actions system * Jarvis, remove all references to CM14 * Fix InventoryUIController crashing when an InventoryGui is not found * Rename mapping1 to mapping * Clean up context calls * Add doc comments * Add delegate for hiding decals in the mapping screen * Jarvis mission failed * a * Add test * Fix not flushing save stream in mapping manager * change * Fix verbs * fixes * localise --------- Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com> Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
47 lines
1.6 KiB
C#
47 lines
1.6 KiB
C#
using System.IO;
|
|
using Lidgren.Network;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Shared.Mapping;
|
|
|
|
public sealed class MappingMapDataMessage : NetMessage
|
|
{
|
|
public override MsgGroups MsgGroup => MsgGroups.Command;
|
|
public override NetDeliveryMethod DeliveryMethod => NetDeliveryMethod.ReliableUnordered;
|
|
|
|
public ZStdCompressionContext Context = default!;
|
|
public string Yml = default!;
|
|
|
|
public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
|
|
{
|
|
MsgSize = buffer.LengthBytes;
|
|
|
|
var uncompressedLength = buffer.ReadVariableInt32();
|
|
var compressedLength = buffer.ReadVariableInt32();
|
|
var stream = new MemoryStream(compressedLength);
|
|
buffer.ReadAlignedMemory(stream, compressedLength);
|
|
using var decompress = new ZStdDecompressStream(stream);
|
|
using var decompressed = new MemoryStream(uncompressedLength);
|
|
|
|
decompress.CopyTo(decompressed, uncompressedLength);
|
|
decompressed.Position = 0;
|
|
serializer.DeserializeDirect(decompressed, out Yml);
|
|
}
|
|
|
|
public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
|
|
{
|
|
var stream = new MemoryStream();
|
|
serializer.SerializeDirect(stream, Yml);
|
|
buffer.WriteVariableInt32((int) stream.Length);
|
|
|
|
stream.Position = 0;
|
|
var buf = new byte[ZStd.CompressBound((int) stream.Length)];
|
|
var length = Context.Compress2(buf, stream.AsSpan());
|
|
|
|
buffer.WriteVariableInt32(length);
|
|
buffer.Write(buf.AsSpan(0, length));
|
|
}
|
|
}
|