From 20820552406d0057538e91cd13d7b71989879a50 Mon Sep 17 00:00:00 2001 From: Denis Date: Sat, 29 Aug 2026 16:53:43 +0400 Subject: [PATCH] fix(mate): a spaced mate name reached the client as two fields A mate named "Joyeux Mouton" split its own field and shifted every field after it on in, sc_p and sc_n. It needed no renaming to reach: the fallback when a mate was never renamed is the creature's own name, and plenty carry a space. The serializer owns the substitution as of 21.1.1, so DisplayName returns the name as it is and the packets carry it unchanged. The test that pinned the caret on the packet object now pins it on the wire, where it belongs, across all three packets. --- Directory.Packages.props | 2 +- .../Services/MateService/MateServiceTests.cs | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 72ad532bd..d9ba14a7e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -44,7 +44,7 @@ - + diff --git a/test/NosCore.GameObject.Tests/Services/MateService/MateServiceTests.cs b/test/NosCore.GameObject.Tests/Services/MateService/MateServiceTests.cs index 80c4d5278..6a307866e 100644 --- a/test/NosCore.GameObject.Tests/Services/MateService/MateServiceTests.cs +++ b/test/NosCore.GameObject.Tests/Services/MateService/MateServiceTests.cs @@ -14,6 +14,8 @@ using NosCore.Data.Dto; using NosCore.Data.Enumerations.Character; using NosCore.Data.StaticEntities; +using NosCore.Packets; +using NosCore.Packets.Interfaces; using NosCore.Packets.ServerPackets.Mates; using NosCore.Shared.Enumerations; using System.Collections.Generic; @@ -327,5 +329,27 @@ public async Task AMateIsNeverPlacedInsideAWallAsync() Assert.IsTrue(walled.IsWalkable(mate.PositionX, mate.PositionY), $"placed at {mate.PositionX},{mate.PositionY}, which is not walkable"); } + + [TestMethod] + public async Task ASpacedMateNameReachesTheClientAsOneFieldAsync() + { + var service = Build(new[] + { + new MateDto { MateId = 1, CharacterId = CharacterId, VNum = ChickenVNum, MateType = MateType.Pet, IsTeamMember = true, Name = "Joyeux Mouton" } + }, Creature(ChickenVNum, "Chicken", 157, 10)); + + var mate = (await service.LoadAsync(CharacterId))[0]; + var serializer = new Serializer(typeof(IPacket).Assembly.GetTypes() + .Where(p => p.GetInterfaces().Contains(typeof(IPacket)) && p.IsClass && !p.IsAbstract) + .ToList()); + + foreach (var packet in new IPacket[] + { mate.GenerateIn(RegionType.EN), mate.GenerateScp(RegionType.EN), mate.GenerateScn(RegionType.EN) }) + { + var line = serializer.Serialize(new[] { packet }).TrimEnd(); + StringAssert.Contains(line, "Joyeux^Mouton", + $"the name has to travel as one field: {line}"); + } + } } }