Skip to content

Commit 069929c

Browse files
committed
Some updates.
1 parent c21cbcd commit 069929c

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

Penumbra/Interop/MaterialPreview/LiveMaterialPreviewer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void SetMaterialParameter(uint parameterCrc, Index offset, Span<float> va
8181
for (var i = 0; i < _shaderPackage->MaterialElementCount; ++i)
8282
{
8383
// TODO fix when CS updated
84-
ref var parameter = ref ((ShaderPackage.MaterialElement*) ((byte*)_shaderPackage + 0xA0))[i];
84+
ref var parameter = ref ((ShaderPackage.MaterialElement*) ((byte*)_shaderPackage + 0x98))[i];
8585
if (parameter.CRC == parameterCrc)
8686
{
8787
if ((parameter.Offset & 0x3) != 0

Penumbra/Interop/MaterialPreview/MaterialInfo.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public static unsafe nint GetDrawObject(DrawObjectType type, nint address)
3333
return type switch
3434
{
3535
DrawObjectType.Character => (nint)gameObject->GameObject.GetDrawObject(),
36-
DrawObjectType.Mainhand => *((nint*)&gameObject->DrawData.MainHand + 1),
37-
DrawObjectType.Offhand => *((nint*)&gameObject->DrawData.OffHand + 1),
38-
DrawObjectType.Vfx => *((nint*)&gameObject->DrawData.UnkF0 + 1),
36+
DrawObjectType.Mainhand => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.MainHand).DrawObject,
37+
DrawObjectType.Offhand => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.OffHand).DrawObject,
38+
DrawObjectType.Vfx => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.Unk).DrawObject,
3939
_ => nint.Zero,
4040
};
4141
}
@@ -72,7 +72,7 @@ public static unsafe List<MaterialInfo> FindMaterials(IEnumerable<nint> gameObje
7272
if (gameObject == null)
7373
continue;
7474

75-
var index = (ObjectIndex) gameObject->GameObject.ObjectIndex;
75+
var index = (ObjectIndex)gameObject->GameObject.ObjectIndex;
7676

7777
foreach (var type in Enum.GetValues<DrawObjectType>())
7878
{
@@ -93,7 +93,7 @@ public static unsafe List<MaterialInfo> FindMaterials(IEnumerable<nint> gameObje
9393
continue;
9494

9595
var mtrlHandle = material->MaterialResourceHandle;
96-
var path = ResolveContext.GetResourceHandlePath((Structs.ResourceHandle*)mtrlHandle);
96+
var path = ResolveContext.GetResourceHandlePath((Structs.ResourceHandle*)mtrlHandle);
9797
if (path == needle)
9898
result.Add(new MaterialInfo(index, type, i, j));
9999
}

Penumbra/Interop/PathResolving/AnimationHookService.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Dalamud.Hooking;
33
using Dalamud.Plugin.Services;
44
using Dalamud.Utility.Signatures;
5+
using FFXIVClientStructs.FFXIV.Client.Game;
56
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
67
using Penumbra.Collections;
78
using Penumbra.Api.Enums;
@@ -37,6 +38,10 @@ public AnimationHookService(PerformanceTracker performance, IObjectTable objects
3738
_conditions = conditions;
3839

3940
interop.InitializeFromAttributes(this);
41+
_loadCharacterSoundHook =
42+
interop.HookFromAddress<LoadCharacterSound>(
43+
(nint)FFXIVClientStructs.FFXIV.Client.Game.Character.Character.VfxContainer.MemberFunctionPointers.LoadCharacterSound,
44+
LoadCharacterSoundDetour);
4045

4146
_loadCharacterSoundHook.Enable();
4247
_loadTimelineResourcesHook.Enable();
@@ -113,9 +118,7 @@ public void Dispose()
113118
/// <summary> Characters load some of their voice lines or whatever with this function. </summary>
114119
private delegate nint LoadCharacterSound(nint character, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7);
115120

116-
// TODO: Use ClientStructs
117-
[Signature(Sigs.LoadCharacterSound, DetourName = nameof(LoadCharacterSoundDetour))]
118-
private readonly Hook<LoadCharacterSound> _loadCharacterSoundHook = null!;
121+
private readonly Hook<LoadCharacterSound> _loadCharacterSoundHook;
119122

120123
private nint LoadCharacterSoundDetour(nint container, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7)
121124
{
@@ -194,16 +197,18 @@ private void LoadSomePapDetour(nint a1, int a2, nint a3, int a4)
194197
_animationLoadData.Value = last;
195198
}
196199

200+
private delegate void SomeActionLoadDelegate(ActionTimelineManager* timelineManager);
201+
197202
/// <summary> Seems to load character actions when zoning or changing class, maybe. </summary>
198203
[Signature(Sigs.LoadSomeAction, DetourName = nameof(SomeActionLoadDetour))]
199-
private readonly Hook<CharacterBaseNoArgumentDelegate> _someActionLoadHook = null!;
204+
private readonly Hook<SomeActionLoadDelegate> _someActionLoadHook = null!;
200205

201-
private void SomeActionLoadDetour(nint gameObject)
206+
private void SomeActionLoadDetour(ActionTimelineManager* timelineManager)
202207
{
203208
using var performance = _performance.Measure(PerformanceType.LoadAction);
204209
var last = _animationLoadData.Value;
205-
_animationLoadData.Value = _collectionResolver.IdentifyCollection((GameObject*)gameObject, true);
206-
_someActionLoadHook.Original(gameObject);
210+
_animationLoadData.Value = _collectionResolver.IdentifyCollection((GameObject*)timelineManager->Parent, true);
211+
_someActionLoadHook.Original(timelineManager);
207212
_animationLoadData.Value = last;
208213
}
209214

0 commit comments

Comments
 (0)