From 83e3e27e7bb08c962a38c371f9bdd0ea4ae1dc37 Mon Sep 17 00:00:00 2001 From: erwan-joly Date: Sun, 30 Aug 2026 12:06:38 +1200 Subject: [PATCH] chore: take NosCore.Packets 21.1.0 and drop the manual mlintro escape The serializer now encodes spaces as "^" itself: for any string that is not the last field, for strings nested in a sub-packet, and for the few fields that declare EscapeSpaces because the client wants them encoded wherever they sit. MlintroPacket.Intro is one of those, so the handler passes the message through as typed. MlEditPacketHandlerTests asserted the caret on the packet object, which is no longer where it appears. It now checks the object carries the message as typed and pins "mlintro Test^Test" on the wire. MinilandEntranceHandler keeps its substitution. It writes the message onto MsgPacket, which five other call sites send unescaped, so the field cannot declare EscapeSpaces without mangling those. --- Directory.Packages.props | 2 +- src/NosCore.PacketHandlers/Miniland/MlobjPacketHandler.cs | 2 +- .../Miniland/MlEditPacketHandlerTests.cs | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index ca38fa549..72ad532bd 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -44,7 +44,7 @@ - + diff --git a/src/NosCore.PacketHandlers/Miniland/MlobjPacketHandler.cs b/src/NosCore.PacketHandlers/Miniland/MlobjPacketHandler.cs index ab621bea1..56789455a 100644 --- a/src/NosCore.PacketHandlers/Miniland/MlobjPacketHandler.cs +++ b/src/NosCore.PacketHandlers/Miniland/MlobjPacketHandler.cs @@ -24,7 +24,7 @@ public override async Task ExecuteAsync(MLEditPacket mlEditPacket, ClientSession switch (mlEditPacket.Type) { case 1: - await clientSession.SendPacketAsync(new MlintroPacket { Intro = mlEditPacket.MinilandInfo!.Replace(' ', '^') }); + await clientSession.SendPacketAsync(new MlintroPacket { Intro = mlEditPacket.MinilandInfo }); miniland.MinilandMessage = mlEditPacket.MinilandInfo; await clientSession.SendPacketAsync(new InfoiPacket { diff --git a/test/NosCore.PacketHandlers.Tests/Miniland/MlEditPacketHandlerTests.cs b/test/NosCore.PacketHandlers.Tests/Miniland/MlEditPacketHandlerTests.cs index f6151a7a6..524110410 100644 --- a/test/NosCore.PacketHandlers.Tests/Miniland/MlEditPacketHandlerTests.cs +++ b/test/NosCore.PacketHandlers.Tests/Miniland/MlEditPacketHandlerTests.cs @@ -4,6 +4,7 @@ // |_|\__|\__/ |___/ \__/\__/|_|_\___| // +using NosCore.Packets; using Mapster; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; @@ -207,7 +208,11 @@ private void MinilandMessageWithSpaceShouldBeChanged() var miniland = MinilandProvider.GetMiniland(Session.Character.CharacterId); Assert.AreEqual("Test Test", miniland.MinilandMessage); var lastpacket2 = (MlintroPacket?)Session.LastPackets.FirstOrDefault(s => s is MlintroPacket); - Assert.AreEqual("Test^Test", lastpacket2?.Intro); + + // The packet carries the message as typed; the "^" encoding is the serializer's, + // which is why MlintroPacket.Intro declares EscapeSpaces. + Assert.AreEqual("Test Test", lastpacket2?.Intro); + Assert.AreEqual("mlintro Test^Test", new Serializer(new[] { typeof(MlintroPacket) }).Serialize(lastpacket2!)); } private void InfoPacketShouldBeSent()