Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into net9-rollup
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Nov 19, 2024
2 parents 26be395 + bf7ef00 commit 44b94c5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 38 deletions.
59 changes: 22 additions & 37 deletions Dalamud/Game/Text/SeStringHandling/Payloads/PlayerPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -84,50 +87,32 @@ public override string ToString()
/// <inheritdoc/>
protected override byte[] EncodeImpl()
{
var chunkLen = this.playerName.Length + 7;
var bytes = new List<byte>()
{
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;
}

/// <inheritdoc/>
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();
}
}
9 changes: 9 additions & 0 deletions Dalamud/Utility/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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}");
}

Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/FFXIVClientStructs
Submodule FFXIVClientStructs updated 29 files
+4 −1 FFXIVClientStructs/FFXIV/Client/Game/Character/Character.cs
+25 −0 FFXIVClientStructs/FFXIV/Client/Game/Character/ModelContainer.cs
+19 −21 FFXIVClientStructs/FFXIV/Client/Game/Character/TimelineContainer.cs
+2 −2 FFXIVClientStructs/FFXIV/Client/Game/Conditions.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/Game/Event/EventSceneTaskInterface.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/Game/GameMain.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/Game/Object/GameObject.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/Game/UI/PlayerState.cs
+5 −4 FFXIVClientStructs/FFXIV/Client/Game/UI/RecipeNote.cs
+2 −2 FFXIVClientStructs/FFXIV/Client/Graphics/Kernel/Texture.cs
+15 −15 FFXIVClientStructs/FFXIV/Client/Graphics/Render/RenderTargetManager.cs
+5 −5 FFXIVClientStructs/FFXIV/Client/Graphics/Scene/CharacterBase.cs
+9 −9 FFXIVClientStructs/FFXIV/Client/Graphics/Scene/Demihuman.cs
+5 −5 FFXIVClientStructs/FFXIV/Client/Graphics/Scene/Monster.cs
+12 −12 FFXIVClientStructs/FFXIV/Client/Graphics/Scene/Weapon.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/UI/AddonNamePlate.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/UI/AddonSalvageDialog.cs
+5 −5 FFXIVClientStructs/FFXIV/Client/UI/Agent/AgentModule.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/UI/Info/InfoProxyPartyInvite.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/UI/Misc/RaptureLogModule.cs
+1 −1 FFXIVClientStructs/FFXIV/Client/UI/Misc/RaptureMacroModule.cs
+3 −3 FFXIVClientStructs/FFXIV/Client/UI/UIModule.cs
+4 −4 FFXIVClientStructs/FFXIV/Client/UI/UIModuleInterface.cs
+2 −2 FFXIVClientStructs/FFXIV/Component/GUI/AtkValue.cs
+1 −1 FFXIVClientStructs/STD/StdDeque.cs
+3 −3 FFXIVClientStructs/STD/StdString.cs
+4 −4 FFXIVClientStructs/STD/StdVector.Default.cs
+2 −2 Ghidra/Getting Started.md
+4,981 −3,940 ida/ffxiv_structs.yml

0 comments on commit 44b94c5

Please sign in to comment.