fix: Use SetValue for FlyText string arrays (#1532)

- Might fix a bug causing crashes with certain FlyText use cases, maybe.
- Also allows building Dalamud under .NET 8 local envs.
This commit is contained in:
KazWolfe 2023-11-18 12:17:18 -08:00 committed by GitHub
parent 48e8462550
commit 93f08a4cb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 26 deletions

View file

@ -1,4 +1,3 @@
using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -113,32 +112,26 @@ internal sealed class FlyTextGui : IDisposable, IServiceType, IFlyTextGui
numArray->IntArray[numOffset + 2] = unchecked((int)val1); numArray->IntArray[numOffset + 2] = unchecked((int)val1);
numArray->IntArray[numOffset + 3] = unchecked((int)val2); numArray->IntArray[numOffset + 3] = unchecked((int)val2);
numArray->IntArray[numOffset + 4] = unchecked((int)damageTypeIcon); // Icons for damage type numArray->IntArray[numOffset + 4] = unchecked((int)damageTypeIcon); // Icons for damage type
numArray->IntArray[numOffset + 5] = 5; // Unknown numArray->IntArray[numOffset + 5] = 5; // Unknown
numArray->IntArray[numOffset + 6] = unchecked((int)color); numArray->IntArray[numOffset + 6] = unchecked((int)color);
numArray->IntArray[numOffset + 7] = unchecked((int)icon); numArray->IntArray[numOffset + 7] = unchecked((int)icon);
numArray->IntArray[numOffset + 8] = 0; // Unknown numArray->IntArray[numOffset + 8] = 0; // Unknown
numArray->IntArray[numOffset + 9] = 0; // Unknown, has something to do with yOffset numArray->IntArray[numOffset + 9] = 0; // Unknown, has something to do with yOffset
fixed (byte* pText1 = text1.Encode()) strArray->SetValue((int)strOffset + 0, text1.Encode(), false, true, false);
{ strArray->SetValue((int)strOffset + 1, text2.Encode(), false, true, false);
fixed (byte* pText2 = text2.Encode())
{
strArray->StringArray[strOffset + 0] = pText1;
strArray->StringArray[strOffset + 1] = pText2;
this.addFlyTextNative( this.addFlyTextNative(
flytext, flytext,
actorIndex, actorIndex,
1, 1,
(IntPtr)numArray, (IntPtr)numArray,
numOffset, numOffset,
10, 10,
(IntPtr)strArray, (IntPtr)strArray,
strOffset, strOffset,
2, 2,
0); 0);
}
}
} }
private static byte[] Terminate(byte[] source) private static byte[] Terminate(byte[] source)
@ -230,7 +223,8 @@ internal sealed class FlyTextGui : IDisposable, IServiceType, IFlyTextGui
if (!dirty) if (!dirty)
{ {
Log.Verbose("[FlyText] Calling flytext with original args."); Log.Verbose("[FlyText] Calling flytext with original args.");
return this.createFlyTextHook.Original(addonFlyText, kind, val1, val2, text2, color, icon, damageTypeIcon, text1, yOffset); return this.createFlyTextHook.Original(addonFlyText, kind, val1, val2, text2, color, icon,
damageTypeIcon, text1, yOffset);
} }
var terminated1 = Terminate(tmpText1.Encode()); var terminated1 = Terminate(tmpText1.Encode());
@ -299,10 +293,10 @@ internal class FlyTextGuiPluginScoped : IDisposable, IServiceType, IFlyTextGui
{ {
this.flyTextGuiService.FlyTextCreated += this.FlyTextCreatedForward; this.flyTextGuiService.FlyTextCreated += this.FlyTextCreatedForward;
} }
/// <inheritdoc/> /// <inheritdoc/>
public event IFlyTextGui.OnFlyTextCreatedDelegate? FlyTextCreated; public event IFlyTextGui.OnFlyTextCreatedDelegate? FlyTextCreated;
/// <inheritdoc/> /// <inheritdoc/>
public void Dispose() public void Dispose()
{ {

View file

@ -1,7 +1,7 @@
{ {
"sdk": { "sdk": {
"version": "7.0.0", "version": "7.0.0",
"rollForward": "latestMinor", "rollForward": "latestMajor",
"allowPrerelease": true "allowPrerelease": true
} }
} }