diff --git a/src/NosCore.Packets/Serializer.cs b/src/NosCore.Packets/Serializer.cs index 4d230542..e53ce85c 100644 --- a/src/NosCore.Packets/Serializer.cs +++ b/src/NosCore.Packets/Serializer.cs @@ -273,7 +273,7 @@ private Expression PacketSerializer(Expression injectedPacket, PacketIndexAttrib return Expression.Condition( Expression.Equal(specificTypeExpression, Expression.Constant(null, typeof(object))), - Expression.Constant(indexAttr.IsOptional ? null : $"{discriminator}-1", typeof(object)), + Expression.Constant(indexAttr.IsOptional ? null : "-1", typeof(object)), Expression.Convert(propExp, typeof(object)) ); } diff --git a/src/NosCore.Packets/ServerPackets/Families/GidxFamilySubPacket.cs b/src/NosCore.Packets/ServerPackets/Families/GidxFamilySubPacket.cs deleted file mode 100644 index 6c02b1b5..00000000 --- a/src/NosCore.Packets/ServerPackets/Families/GidxFamilySubPacket.cs +++ /dev/null @@ -1,19 +0,0 @@ -// __ _ __ __ ___ __ ___ ___ -// | \| |/__\ /' _/ / _//__\| _ \ __| -// | | ' | \/ |`._`.| \_| \/ | v / _| -// |_|\__|\__/ |___/ \__/\__/|_|_\___| -// ----------------------------------- - -using NosCore.Packets.Attributes; - -namespace NosCore.Packets.ServerPackets.Families -{ - public class GidxFamilySubPacket : PacketBase - { - [PacketIndex(0)] - public int ServerId { get; set; } - - [PacketIndex(1)] - public long FamilyId { get; set; } - } -} diff --git a/src/NosCore.Packets/ServerPackets/Families/GidxPacket.cs b/src/NosCore.Packets/ServerPackets/Families/GidxPacket.cs index 6643cc0d..ab4919a7 100644 --- a/src/NosCore.Packets/ServerPackets/Families/GidxPacket.cs +++ b/src/NosCore.Packets/ServerPackets/Families/GidxPacket.cs @@ -20,8 +20,8 @@ public class GidxPacket : PacketBase [PacketIndex(1)] public long VisualId { get; set; } - [PacketIndex(2, SpecialSeparator = ".")] - public GidxFamilySubPacket? FamilyIdentifier { get; set; } + [PacketIndex(2)] + public long? FamilyId { get; set; } [PacketIndex(3)] public string? FamilyName { get; set; } diff --git a/src/NosCore.Packets/ServerPackets/Mates/ScnPacket.cs b/src/NosCore.Packets/ServerPackets/Mates/ScnPacket.cs index baa04152..6b0161f9 100644 --- a/src/NosCore.Packets/ServerPackets/Mates/ScnPacket.cs +++ b/src/NosCore.Packets/ServerPackets/Mates/ScnPacket.cs @@ -42,7 +42,7 @@ public class ScnPacket : PacketBase [PacketIndex(8, SpecialSeparator = ".")] public ScEquipmentDetails? GauntletInstanceDetails { get; set; } - [PacketIndex(9)] + [PacketIndex(9, SpecialSeparator = ".")] public ScEquipmentDetails? BootsInstanceDetails { get; set; } [PacketIndex(10)] diff --git a/test/NosCore.Packets.Tests/SerializerTest.cs b/test/NosCore.Packets.Tests/SerializerTest.cs index 3c2a5c77..805efb77 100644 --- a/test/NosCore.Packets.Tests/SerializerTest.cs +++ b/test/NosCore.Packets.Tests/SerializerTest.cs @@ -34,6 +34,7 @@ using NosCore.Shared.Enumerations; using System.Collections.Generic; using System.Linq; +using ServerGidxPacket = NosCore.Packets.ServerPackets.Families.GidxPacket; namespace NosCore.Packets.Tests { @@ -519,24 +520,39 @@ public void SerializeWithNullFirstParam() packet); } + // gidx exists on both sides with different shapes, and the serializer keys on the simple + // type name, so the server one needs its own instance. + private static readonly ISerializer ServerSerializer = + new Serializer(new[] { typeof(ServerGidxPacket) }); + + [TestMethod] + public void SerializeGidxWithoutFamily() + { + var packet = ServerSerializer.Serialize(new ServerGidxPacket + { + VisualType = VisualType.Player, + VisualId = 741328, + FamilyId = null, + FamilyName = "-", + FamilyLevel = 0 + }); + + Assert.AreEqual("gidx 1 741328 -1 - 0 ", packet); + } + [TestMethod] - public void SerializeWithNullSubPacketKeepsTheSeparator() + public void SerializeGidxWithFamily() { - var packet = Serializer.Serialize(new ScnPacket + var packet = ServerSerializer.Serialize(new ServerGidxPacket { - PetId = 1, - NpcMonsterVNum = 319, - TransportId = 26719, - Level = 50, - Loyalty = 1000, - Experience = 1536, - WeaponInstanceDetails = new ScnPacket.ScEquipmentDetails { ItemId = 990 }, - Name = "Kliff", - MorphId = -1 + VisualType = VisualType.Player, + VisualId = 741328, + FamilyId = 5052, + FamilyName = "-Nemesis-", + FamilyLevel = 7 }); - Assert.IsTrue(packet.StartsWith("sc_n 1 319 26719 50 1000 1536 990.0.0 -1 -1 -1 "), - $"the -1 of a null sub-packet must not be glued to the field before it: {packet}"); + Assert.AreEqual("gidx 1 741328 5052 -Nemesis- 7 ", packet); } [TestMethod]