chore: Bump ClientStructs and make it build again

This commit is contained in:
Kaz Wolfe 2025-03-24 13:25:13 -07:00
parent 9e3c03d0e8
commit 2176b32219
No known key found for this signature in database
GPG key ID: 258813F53A16EBB4
16 changed files with 92 additions and 80 deletions

View file

@ -90,6 +90,7 @@
<ItemGroup>
<ProjectReference Include="..\Dalamud.Common\Dalamud.Common.csproj" />
<ProjectReference Include="..\lib\FFXIVClientStructs\FFXIVClientStructs\FFXIVClientStructs.csproj" />
<ProjectReference Include="..\lib\FFXIVClientStructs\InteropGenerator.Runtime\InteropGenerator.Runtime.csproj" />
<ProjectReference Include="..\lib\ImGuiScene\deps\ImGui.NET\src\ImGui.NET-472\ImGui.NET-472.csproj" />
<ProjectReference Include="..\lib\ImGuiScene\deps\SDL2-CS\SDL2-CS.csproj" />
<ProjectReference Include="..\lib\ImGuiScene\ImGuiScene\ImGuiScene.csproj" />

View file

@ -24,7 +24,7 @@ internal unsafe class AddonEventListener : IDisposable
this.eventListener = (AtkEventListener*)Marshal.AllocHGlobal(sizeof(AtkEventListener));
this.eventListener->VirtualTable = (AtkEventListener.AtkEventListenerVirtualTable*)Marshal.AllocHGlobal(sizeof(void*) * 3);
this.eventListener->VirtualTable->Dtor = (delegate* unmanaged<AtkEventListener*, byte, void>)(delegate* unmanaged<void>)&NullSub;
this.eventListener->VirtualTable->Dtor = (delegate* unmanaged<AtkEventListener*, byte, AtkEventListener*>)(delegate* unmanaged<void>)&NullSub;
this.eventListener->VirtualTable->ReceiveGlobalEvent = (delegate* unmanaged<AtkEventListener*, AtkEventType, int, AtkEvent*, AtkEventData*, void>)(delegate* unmanaged<void>)&NullSub;
this.eventListener->VirtualTable->ReceiveEvent = (delegate* unmanaged<AtkEventListener*, AtkEventType, int, AtkEvent*, AtkEventData*, void>)Marshal.GetFunctionPointerForDelegate(this.receiveEventDelegate);
}

View file

@ -42,8 +42,10 @@ public unsafe class Status
/// <summary>
/// Gets the stack count of this status.
/// Only valid if this is a non-food status.
/// </summary>
public byte StackCount => this.Struct->StackCount;
[Obsolete($"Replaced with {nameof(Param)}", true)]
public byte StackCount => (byte)this.Struct->Param;
/// <summary>
/// Gets the time remaining of this status.

View file

@ -526,8 +526,8 @@ public class GameConfigSection
{
if (!this.enumMap.TryGetValue(entry->Index, out var enumObject))
{
if (entry->Name == null) return null;
var name = MemoryHelper.ReadStringNullTerminated(new IntPtr(entry->Name));
if (entry->Name.Value == null) return null;
var name = entry->Name.ToString();
if (Enum.TryParse(typeof(TEnum), name, out enumObject))
{
this.enumMap.TryAdd(entry->Index, enumObject);
@ -556,12 +556,12 @@ public class GameConfigSection
var e = configBase->ConfigEntry;
for (var i = 0U; i < configBase->ConfigCount; i++, e++)
{
if (e->Name == null)
if (e->Name.Value == null)
{
continue;
}
var eName = MemoryHelper.ReadStringNullTerminated(new IntPtr(e->Name));
var eName = e->Name.ToString();
if (eName.Equals(name))
{
this.indexMap.TryAdd(name, i);

View file

@ -55,10 +55,16 @@ public unsafe struct GameInventoryItem : IEquatable<GameInventoryItem>
/// </summary>
public int Quantity => this.InternalItem.Quantity;
/// <summary>
/// Gets the spiritbond or collectability of this item.
/// </summary>
public uint SpiritbondOrCollectability => this.InternalItem.SpiritbondOrCollectability;
/// <summary>
/// Gets the spiritbond of this item.
/// </summary>
public uint Spiritbond => this.InternalItem.Spiritbond;
[Obsolete($"Renamed to {nameof(SpiritbondOrCollectability)}", true)]
public uint Spiritbond => this.SpiritbondOrCollectability;
/// <summary>
/// Gets the repair condition of this item.

View file

@ -565,7 +565,7 @@ internal unsafe class NetworkHandlers : IInternalDisposableService
return this.configuration.IsMbCollect;
}
private void MarketPurchasePacketDetour(PacketDispatcher* a1, nint packetData)
private void MarketPurchasePacketDetour(uint targetId, nint packetData)
{
try
{
@ -576,7 +576,7 @@ internal unsafe class NetworkHandlers : IInternalDisposableService
Log.Error(ex, "MarketPurchasePacketHandler threw an exception");
}
this.mbPurchaseHook.OriginalDisposeSafe(a1, packetData);
this.mbPurchaseHook.OriginalDisposeSafe(targetId, packetData);
}
private void MarketHistoryPacketDetour(InfoProxyItemSearch* a1, nint packetData)
@ -609,7 +609,7 @@ internal unsafe class NetworkHandlers : IInternalDisposableService
this.customTalkHook.OriginalDisposeSafe(a1, eventId, responseId, args, argCount);
}
private void MarketItemRequestStartDetour(PacketDispatcher* a1, nint packetRef)
private void MarketItemRequestStartDetour(uint targetId, nint packetRef)
{
try
{
@ -620,7 +620,7 @@ internal unsafe class NetworkHandlers : IInternalDisposableService
Log.Error(ex, "MarketItemRequestStartDetour threw an exception");
}
this.mbItemRequestStartHook.OriginalDisposeSafe(a1, packetRef);
this.mbItemRequestStartHook.OriginalDisposeSafe(targetId, packetRef);
}
private void MarketBoardOfferingsDetour(InfoProxyItemSearch* a1, nint packetRef)

View file

@ -1744,7 +1744,7 @@ internal class SeStringEvaluator : IServiceType, ISeStringEvaluator
return false;
case TextParameterType.String:
this.EvaluateAndAppendTo(builder, new(p.StringValue), null, language);
this.EvaluateAndAppendTo(builder, p.StringValue.AsReadOnlySeStringSpan(), null, language);
return false;
case TextParameterType.Uninitialized:

View file

@ -225,7 +225,7 @@ internal unsafe class UiDebug
ImGui.SameLine();
if (ImGui.Button($"Decode##{(ulong)textNode:X}"))
textNode->NodeText.SetString(new ReadOnlySeStringSpan(textNode->NodeText.StringPtr).ToString());
textNode->NodeText.SetString(textNode->NodeText.StringPtr.AsReadOnlySeStringSpan().ToString());
ImGui.Text($"AlignmentType: {(AlignmentType)textNode->AlignmentFontType} FontSize: {textNode->FontSize}");
int b = textNode->AlignmentFontType;

View file

@ -76,14 +76,13 @@ public unsafe partial class AddonTree
case ValueType.String8:
case ValueType.String:
{
if (atkValue->String == null)
if (atkValue->String.Value == null)
{
ImGui.TextDisabled("null");
}
else
{
var str = MemoryHelper.ReadSeStringNullTerminated(new nint(atkValue->String));
Util.ShowStruct(str, (ulong)atkValue);
Util.ShowStruct(atkValue->String.ToString(), (ulong)atkValue);
}
break;

View file

@ -89,7 +89,7 @@ internal unsafe partial class TextNodeTree : ResNodeTree
var seStringBytes = new byte[utf8String.BufUsed];
for (var i = 0L; i < utf8String.BufUsed; i++)
{
seStringBytes[i] = utf8String.StringPtr[i];
seStringBytes[i] = utf8String.StringPtr.Value[i];
}
var seString = SeString.Parse(seStringBytes);

View file

@ -299,8 +299,8 @@ internal class SeStringCreatorWidget : IDataWindowWidget
break;
case TextParameterType.String:
if (item.StringValue != null)
WidgetUtil.DrawCopyableText(MemoryHelper.ReadStringNullTerminated((nint)item.StringValue));
if (item.StringValue.Value != null)
WidgetUtil.DrawCopyableText(item.StringValue.ToString());
else
ImGui.TextUnformatted("null");
break;

View file

@ -442,7 +442,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
textNode->TextFlags |= (byte)TextFlags.MultiLine;
textNode->AlignmentType = AlignmentType.TopLeft;
var containsDalamudVersionString = textNode->OriginalTextPointer == textNode->NodeText.StringPtr;
var containsDalamudVersionString = textNode->OriginalTextPointer.Value == textNode->NodeText.StringPtr.Value;
if (!this.configuration.ShowTsm || !this.showTsm.Value)
{
if (containsDalamudVersionString)
@ -460,7 +460,7 @@ internal class TitleScreenMenuWindow : Window, IDisposable
this.lastLoadedPluginCount = count;
var lssb = LSeStringBuilder.SharedPool.Get();
lssb.Append(new ReadOnlySeStringSpan(addon->AtkValues[1].String)).Append("\n\n");
lssb.Append(new ReadOnlySeStringSpan(addon->AtkValues[1].String.Value)).Append("\n\n");
lssb.PushEdgeColorType(701).PushColorType(539)
.Append(SeIconChar.BoxedLetterD.ToIconChar())
.PopColorType().PopEdgeColorType();

View file

@ -9,7 +9,7 @@ using Dalamud.Plugin.Services;
using Dalamud.Utility;
using Dalamud.Utility.TerraFxCom;
using Lumina.Data.Files;
using FFXIVClientStructs.FFXIV.Client.Graphics.Kernel;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
@ -24,32 +24,30 @@ internal sealed partial class TextureManager
(nint)this.ConvertToKernelTexture(wrap, leaveWrapOpen);
/// <inheritdoc cref="ITextureProvider.ConvertToKernelTexture"/>
public unsafe FFXIVClientStructs.FFXIV.Client.Graphics.Kernel.Texture* ConvertToKernelTexture(
IDalamudTextureWrap wrap,
bool leaveWrapOpen = false)
public unsafe Texture* ConvertToKernelTexture(IDalamudTextureWrap wrap, bool leaveWrapOpen = false)
{
using var wrapAux = new WrapAux(wrap, leaveWrapOpen);
var flags = TexFile.Attribute.TextureType2D;
var flags = TextureFlags.TextureType2D;
if (wrapAux.Desc.Usage == D3D11_USAGE.D3D11_USAGE_IMMUTABLE)
flags |= TexFile.Attribute.Immutable;
flags |= TextureFlags.Immutable;
if (wrapAux.Desc.Usage == D3D11_USAGE.D3D11_USAGE_DYNAMIC)
flags |= TexFile.Attribute.ReadWrite;
flags |= TextureFlags.ReadWrite;
if ((wrapAux.Desc.CPUAccessFlags & (uint)D3D11_CPU_ACCESS_FLAG.D3D11_CPU_ACCESS_READ) != 0)
flags |= TexFile.Attribute.CpuRead;
flags |= TextureFlags.CpuRead;
if ((wrapAux.Desc.BindFlags & (uint)D3D11_BIND_FLAG.D3D11_BIND_RENDER_TARGET) != 0)
flags |= TexFile.Attribute.TextureRenderTarget;
flags |= TextureFlags.TextureRenderTarget;
if ((wrapAux.Desc.BindFlags & (uint)D3D11_BIND_FLAG.D3D11_BIND_DEPTH_STENCIL) != 0)
flags |= TexFile.Attribute.TextureDepthStencil;
flags |= TextureFlags.TextureDepthStencil;
if (wrapAux.Desc.ArraySize != 1)
throw new NotSupportedException("TextureArray2D is currently not supported.");
var gtex = FFXIVClientStructs.FFXIV.Client.Graphics.Kernel.Texture.CreateTexture2D(
var gtex = Texture.CreateTexture2D(
(int)wrapAux.Desc.Width,
(int)wrapAux.Desc.Height,
(byte)wrapAux.Desc.MipLevels,
(uint)TexFile.TextureFormat.Null, // instructs the game to skip preprocessing it seems
(uint)flags,
0, // instructs the game to skip preprocessing it seems
flags,
0);
// Kernel::Texture owns these resources. We're passing the ownership to them.
@ -57,28 +55,27 @@ internal sealed partial class TextureManager
wrapAux.SrvPtr->AddRef();
// Not sure this is needed
var ltf = wrapAux.Desc.Format switch
gtex->TextureFormat = wrapAux.Desc.Format switch
{
DXGI_FORMAT.DXGI_FORMAT_R32G32B32A32_FLOAT => TexFile.TextureFormat.R32G32B32A32F,
DXGI_FORMAT.DXGI_FORMAT_R16G16B16A16_FLOAT => TexFile.TextureFormat.R16G16B16A16F,
DXGI_FORMAT.DXGI_FORMAT_R32G32_FLOAT => TexFile.TextureFormat.R32G32F,
DXGI_FORMAT.DXGI_FORMAT_R16G16_FLOAT => TexFile.TextureFormat.R16G16F,
DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT => TexFile.TextureFormat.R32F,
DXGI_FORMAT.DXGI_FORMAT_R24G8_TYPELESS => TexFile.TextureFormat.D24S8,
DXGI_FORMAT.DXGI_FORMAT_R16_TYPELESS => TexFile.TextureFormat.D16,
DXGI_FORMAT.DXGI_FORMAT_A8_UNORM => TexFile.TextureFormat.A8,
DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM => TexFile.TextureFormat.BC1,
DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM => TexFile.TextureFormat.BC2,
DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM => TexFile.TextureFormat.BC3,
DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM => TexFile.TextureFormat.BC5,
DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM => TexFile.TextureFormat.B4G4R4A4,
DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM => TexFile.TextureFormat.B5G5R5A1,
DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM => TexFile.TextureFormat.B8G8R8A8,
DXGI_FORMAT.DXGI_FORMAT_B8G8R8X8_UNORM => TexFile.TextureFormat.B8G8R8X8,
DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM => TexFile.TextureFormat.BC7,
_ => TexFile.TextureFormat.Null,
DXGI_FORMAT.DXGI_FORMAT_R32G32B32A32_FLOAT => TextureFormat.R32G32B32A32_FLOAT,
DXGI_FORMAT.DXGI_FORMAT_R16G16B16A16_FLOAT => TextureFormat.R16G16B16A16_FLOAT,
DXGI_FORMAT.DXGI_FORMAT_R32G32_FLOAT => TextureFormat.R32G32_FLOAT,
DXGI_FORMAT.DXGI_FORMAT_R16G16_FLOAT => TextureFormat.R16G16_FLOAT,
DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT => TextureFormat.R32_FLOAT,
DXGI_FORMAT.DXGI_FORMAT_R24G8_TYPELESS => TextureFormat.D24_UNORM_S8_UINT,
DXGI_FORMAT.DXGI_FORMAT_R16_TYPELESS => TextureFormat.D16_UNORM,
DXGI_FORMAT.DXGI_FORMAT_A8_UNORM => TextureFormat.A8_UNORM,
DXGI_FORMAT.DXGI_FORMAT_BC1_UNORM => TextureFormat.BC1_UNORM,
DXGI_FORMAT.DXGI_FORMAT_BC2_UNORM => TextureFormat.BC2_UNORM,
DXGI_FORMAT.DXGI_FORMAT_BC3_UNORM => TextureFormat.BC3_UNORM,
DXGI_FORMAT.DXGI_FORMAT_BC5_UNORM => TextureFormat.BC5_UNORM,
DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM => TextureFormat.B4G4R4A4_UNORM,
DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM => TextureFormat.B5G5R5A1_UNORM,
DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM => TextureFormat.B8G8R8A8_UNORM,
DXGI_FORMAT.DXGI_FORMAT_B8G8R8X8_UNORM => TextureFormat.B8G8R8X8_UNORM,
DXGI_FORMAT.DXGI_FORMAT_BC7_UNORM => TextureFormat.BC7_UNORM,
_ => 0,
};
gtex->TextureFormat = (FFXIVClientStructs.FFXIV.Client.Graphics.Kernel.TextureFormat)ltf;
gtex->D3D11Texture2D = wrapAux.TexPtr;
gtex->D3D11ShaderResourceView = wrapAux.SrvPtr;

View file

@ -1,5 +1,7 @@
using System.Linq;
using InteropGenerator.Runtime;
using Lumina.Text.Parse;
using Lumina.Text.ReadOnly;
@ -226,4 +228,9 @@ public static class SeStringExtensions
var replaced = ReplaceText(new ReadOnlySeString(builder.GetViewAsMemory()), toFind, replacement);
builder.Clear().Append(replaced);
}
public static unsafe ReadOnlySeStringSpan AsReadOnlySeStringSpan(this CStringPointer ptr)
{
return new ReadOnlySeStringSpan(ptr.Value);
}
}

@ -1 +1 @@
Subproject commit 2c3e84640af5220b78b944a06fdca79c52144075
Subproject commit 3c99b4f8f7f56ee4defd3ee75809c73312359f9e