Skip to content

Commit

Permalink
Фикс экспорта карт
Browse files Browse the repository at this point in the history
  • Loading branch information
FaDeOkno committed Jan 21, 2025
1 parent 5889852 commit 1b76c6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Content.Client/ADT/Administration/ExportManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override async void Load(ExportYmlMessage msg)

if (data != null)
{
await stream.WriteAsync(Encoding.ASCII.GetBytes(data));
await stream.WriteAsync(Encoding.UTF8.GetBytes(data));
await stream.FlushAsync();
await stream.DisposeAsync();
return;
Expand Down
15 changes: 13 additions & 2 deletions Content.Shared/ADT/Administration/ExportMessage.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Text;
using Lidgren.Network;
using Robust.Shared.Network;
using Robust.Shared.Serialization;
Expand All @@ -12,11 +13,21 @@ public sealed class ExportYmlMessage : NetMessage

public override void ReadFromBuffer(NetIncomingMessage buffer, IRobustSerializer serializer)
{
Data = buffer.ReadString();
// Read the length of the byte array
int length = buffer.ReadInt32();
// Read the byte array
byte[] dataBytes = buffer.ReadBytes(length);
// Decode the byte array to a string using UTF-8 encoding
Data = Encoding.UTF8.GetString(dataBytes);
}

public override void WriteToBuffer(NetOutgoingMessage buffer, IRobustSerializer serializer)
{
buffer.Write(Data);
// Encode the string to a byte array using UTF-8 encoding
byte[] dataBytes = Encoding.UTF8.GetBytes(Data);
// Write the length of the byte array
buffer.Write(dataBytes.Length);
// Write the byte array
buffer.Write(dataBytes);
}
}

0 comments on commit 1b76c6b

Please sign in to comment.