From d856f657c2b241cd16e2dc7e5c8836643d08cc7f Mon Sep 17 00:00:00 2001 From: bleatbot <106497096+bleatbot@users.noreply.github.com> Date: Sun, 17 Nov 2024 14:59:39 +0100 Subject: [PATCH 1/5] [master] Update ClientStructs (#2101) Co-authored-by: github-actions[bot] --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 33a98af53..6ef1f01dc 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 33a98af530e52d5b54714ec9f7704c07bf9fdd91 +Subproject commit 6ef1f01dc12162e271b65705990b8175330806ca From d538ce6350ac464145b42cf90e1222ee133d38bf Mon Sep 17 00:00:00 2001 From: bleatbot <106497096+bleatbot@users.noreply.github.com> Date: Sun, 17 Nov 2024 19:46:17 +0100 Subject: [PATCH 2/5] Update ClientStructs (#2103) Co-authored-by: github-actions[bot] --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 6ef1f01dc..76b8b8982 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 6ef1f01dc12162e271b65705990b8175330806ca +Subproject commit 76b8b8982b57cd85eed5a5f509feee0442ca1b6f From 2f502767386320d84192cc6acd2971d17931e31a Mon Sep 17 00:00:00 2001 From: Infi Date: Tue, 19 Nov 2024 02:29:53 +0100 Subject: [PATCH 3/5] Switch PlayerPayload Encode/Decode to using Lumina (#2107) * Switch PlayerPayload Encode/Decode to using Lumina - This also fixes a bug that PlayerPayload would encode worldIds as byte (they are ushort) * Remove comment --- .../Payloads/PlayerPayload.cs | 59 +++++++------------ 1 file changed, 22 insertions(+), 37 deletions(-) diff --git a/Dalamud/Game/Text/SeStringHandling/Payloads/PlayerPayload.cs b/Dalamud/Game/Text/SeStringHandling/Payloads/PlayerPayload.cs index 07a13e5a3..55697782e 100644 --- a/Dalamud/Game/Text/SeStringHandling/Payloads/PlayerPayload.cs +++ b/Dalamud/Game/Text/SeStringHandling/Payloads/PlayerPayload.cs @@ -6,6 +6,9 @@ using Lumina.Excel; using Lumina.Excel.Sheets; +using Lumina.Text.Payloads; +using Lumina.Text.ReadOnly; + using Newtonsoft.Json; namespace Dalamud.Game.Text.SeStringHandling.Payloads; @@ -84,50 +87,32 @@ public override string ToString() /// protected override byte[] EncodeImpl() { - var chunkLen = this.playerName.Length + 7; - var bytes = new List() - { - START_BYTE, - (byte)SeStringChunkType.Interactable, (byte)chunkLen, (byte)EmbeddedInfoType.PlayerName, - /* unk */ 0x01, - (byte)(this.serverId + 1), // I didn't want to deal with single-byte values in MakeInteger, so we have to do the +1 manually - /* unk */ 0x01, - /* unk */ 0xFF, // these sometimes vary but are frequently this - (byte)(this.playerName.Length + 1), - }; - - bytes.AddRange(Encoding.UTF8.GetBytes(this.playerName)); - bytes.Add(END_BYTE); - - // TODO: should these really be here? additional payloads should come in separately already... - - // encoded names are followed by the name in plain text again - // use the payload parsing for consistency, as this is technically a new chunk - bytes.AddRange(new TextPayload(this.playerName).Encode()); - - // unsure about this entire packet, but it seems to always follow a name - bytes.AddRange(new byte[] - { - START_BYTE, (byte)SeStringChunkType.Interactable, 0x07, (byte)EmbeddedInfoType.LinkTerminator, - 0x01, 0x01, 0x01, 0xFF, 0x01, - END_BYTE, - }); - - return bytes.ToArray(); + var ssb = Lumina.Text.SeStringBuilder.SharedPool.Get(); + var res = ssb + .PushLinkCharacter(this.playerName, this.serverId) + .Append(this.playerName) + .PopLink() + .ToArray(); + Lumina.Text.SeStringBuilder.SharedPool.Return(ssb); + return res; } /// protected override void DecodeImpl(BinaryReader reader, long endOfStream) { - // unk - reader.ReadByte(); + var body = reader.ReadBytes((int)(endOfStream - reader.BaseStream.Position)); + var rosps = new ReadOnlySePayloadSpan(ReadOnlySePayloadType.Macro, MacroCode.Link, body.AsSpan()); + + if (!rosps.TryGetExpression(out _, out var worldIdExpression, out _, out var characterNameExpression)) + return; - this.serverId = GetInteger(reader); + if (!worldIdExpression.TryGetUInt(out var worldId)) + return; - // unk - reader.ReadBytes(2); + if (!characterNameExpression.TryGetString(out var characterName)) + return; - var nameLen = (int)GetInteger(reader); - this.playerName = Encoding.UTF8.GetString(reader.ReadBytes(nameLen)); + this.serverId = worldId; + this.playerName = characterName.ExtractText(); } } From 192dc9c3c3b37b12faac4d2776f42c21365c98e0 Mon Sep 17 00:00:00 2001 From: ItsBexy <103910869+ItsBexy@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:30:12 -0700 Subject: [PATCH 4/5] Update Util.ShowStruct() (#2104) - Now prints field offsets, if/when they are defined. - Fixed a bug wherein Boolean fields were being printed with incorrect values (now tries reading the value as a byte, which seems to do the trick) --- Dalamud/Utility/Util.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Dalamud/Utility/Util.cs b/Dalamud/Utility/Util.cs index 15327a66c..805532025 100644 --- a/Dalamud/Utility/Util.cs +++ b/Dalamud/Utility/Util.cs @@ -1203,6 +1203,8 @@ private static void ShowStructInternal(object obj, ulong addr, bool autoExpand = .GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.Instance)) { var fixedBuffer = (FixedBufferAttribute)f.GetCustomAttribute(typeof(FixedBufferAttribute)); + var offset = (FieldOffsetAttribute)f.GetCustomAttribute(typeof(FieldOffsetAttribute)); + if (fixedBuffer != null) { ImGui.Text($"fixed"); @@ -1212,6 +1214,11 @@ private static void ShowStructInternal(object obj, ulong addr, bool autoExpand = } else { + if (offset != null) + { + ImGui.TextDisabled($"[0x{offset.Value:X}]"); + ImGui.SameLine(); + } ImGui.TextColored(new Vector4(0.2f, 0.9f, 0.9f, 1), $"{f.FieldType.Name}"); } @@ -1224,6 +1231,8 @@ private static void ShowStructInternal(object obj, ulong addr, bool autoExpand = { if (f.FieldType.IsGenericType && (f.FieldType.IsByRef || f.FieldType.IsByRefLike)) ImGui.Text("Cannot preview ref typed fields."); // object never contains ref struct + else if (f.FieldType == typeof(bool) && offset != null) + ShowValue(addr, pathList, f.FieldType, Marshal.ReadByte((nint)addr + offset.Value) > 0, hideAddress); else ShowValue(addr, pathList, f.FieldType, f.GetValue(obj), hideAddress); } From bf7ef00ec0ba2733628defc6d7e2b4764ebbe3e2 Mon Sep 17 00:00:00 2001 From: bleatbot <106497096+bleatbot@users.noreply.github.com> Date: Tue, 19 Nov 2024 02:30:47 +0100 Subject: [PATCH 5/5] Update ClientStructs (#2105) Co-authored-by: github-actions[bot] --- lib/FFXIVClientStructs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/FFXIVClientStructs b/lib/FFXIVClientStructs index 76b8b8982..897f9996d 160000 --- a/lib/FFXIVClientStructs +++ b/lib/FFXIVClientStructs @@ -1 +1 @@ -Subproject commit 76b8b8982b57cd85eed5a5f509feee0442ca1b6f +Subproject commit 897f9996dfa65046c8cf2848c4f783c9ce3b858e