From fac930ad0339c172832a7f64dd8d451367ca3dfa Mon Sep 17 00:00:00 2001 From: Denis Date: Sun, 30 Aug 2026 22:06:34 +0400 Subject: [PATCH] fix(einfo): the monster name is the last field, so it has to opt into escaping A trailing string field keeps its spaces unless it asks not to, and a monster name is the last field of e_info. 929 of the 1109 monster info lines in a real capture carry a space, across 630 distinct names, so without the flag the field splits and everything after the first word is read as extra fields. Co-Authored-By: Claude Opus 5 --- .../ServerPackets/Inventory/EInfoNpcMonsterPacket.cs | 2 +- test/NosCore.Packets.Tests/StringFieldSeparatorTests.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/NosCore.Packets/ServerPackets/Inventory/EInfoNpcMonsterPacket.cs b/src/NosCore.Packets/ServerPackets/Inventory/EInfoNpcMonsterPacket.cs index 62af08e0..db567cbc 100644 --- a/src/NosCore.Packets/ServerPackets/Inventory/EInfoNpcMonsterPacket.cs +++ b/src/NosCore.Packets/ServerPackets/Inventory/EInfoNpcMonsterPacket.cs @@ -92,7 +92,7 @@ public class EInfoNpcMonsterPacket : PacketBase [PacketIndex(24)] public int Unknown { get; set; } = -1; - [PacketIndex(25)] + [PacketIndex(25, EscapeSpaces = true)] public string? Name { get; set; } } } diff --git a/test/NosCore.Packets.Tests/StringFieldSeparatorTests.cs b/test/NosCore.Packets.Tests/StringFieldSeparatorTests.cs index 75973a0c..248aaf74 100644 --- a/test/NosCore.Packets.Tests/StringFieldSeparatorTests.cs +++ b/test/NosCore.Packets.Tests/StringFieldSeparatorTests.cs @@ -10,6 +10,7 @@ using NosCore.Packets.Interfaces; using NosCore.Packets.ServerPackets.Mates; using NosCore.Packets.ServerPackets.Groups; +using NosCore.Packets.ServerPackets.Inventory; using NosCore.Packets.ServerPackets.Miniland; using NosCore.Packets.ServerPackets.Visibility; using System.Collections.Generic; @@ -42,7 +43,8 @@ public class StringFieldSeparatorTests { typeof(SeparatorProbePacket), typeof(DottedProbePacket), typeof(ScpPacket), typeof(ScnPacket), typeof(InPacket), - typeof(PinitPacket), typeof(MlintroPacket), typeof(MlInfoBrPacket) + typeof(PinitPacket), typeof(MlintroPacket), typeof(MlInfoBrPacket), + typeof(EInfoNpcMonsterPacket) }); [TestMethod] @@ -118,6 +120,10 @@ public void AFieldThatOptsInIsEscapedEvenThoughItIsLast() StringAssert.Contains( Serializer.Serialize(new MlInfoBrPacket { Name = "Bob", MinilandMessage = "hello there" }), "hello^there"); + + StringAssert.Contains( + Serializer.Serialize(new EInfoNpcMonsterPacket { Name = "Mother Cuby" }), + "Mother^Cuby"); } [TestMethod]