Some updates.

This commit is contained in:
Ottermandias 2023-10-04 20:30:04 +02:00
parent c21cbcdcd3
commit 069929ce24
3 changed files with 18 additions and 13 deletions

View file

@ -81,7 +81,7 @@ public sealed unsafe class LiveMaterialPreviewer : LiveMaterialPreviewerBase
for (var i = 0; i < _shaderPackage->MaterialElementCount; ++i) for (var i = 0; i < _shaderPackage->MaterialElementCount; ++i)
{ {
// TODO fix when CS updated // TODO fix when CS updated
ref var parameter = ref ((ShaderPackage.MaterialElement*) ((byte*)_shaderPackage + 0xA0))[i]; ref var parameter = ref ((ShaderPackage.MaterialElement*) ((byte*)_shaderPackage + 0x98))[i];
if (parameter.CRC == parameterCrc) if (parameter.CRC == parameterCrc)
{ {
if ((parameter.Offset & 0x3) != 0 if ((parameter.Offset & 0x3) != 0

View file

@ -33,9 +33,9 @@ public readonly record struct MaterialInfo(ObjectIndex ObjectIndex, DrawObjectTy
return type switch return type switch
{ {
DrawObjectType.Character => (nint)gameObject->GameObject.GetDrawObject(), DrawObjectType.Character => (nint)gameObject->GameObject.GetDrawObject(),
DrawObjectType.Mainhand => *((nint*)&gameObject->DrawData.MainHand + 1), DrawObjectType.Mainhand => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.MainHand).DrawObject,
DrawObjectType.Offhand => *((nint*)&gameObject->DrawData.OffHand + 1), DrawObjectType.Offhand => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.OffHand).DrawObject,
DrawObjectType.Vfx => *((nint*)&gameObject->DrawData.UnkF0 + 1), DrawObjectType.Vfx => (nint)gameObject->DrawData.Weapon(DrawDataContainer.WeaponSlot.Unk).DrawObject,
_ => nint.Zero, _ => nint.Zero,
}; };
} }
@ -72,7 +72,7 @@ public readonly record struct MaterialInfo(ObjectIndex ObjectIndex, DrawObjectTy
if (gameObject == null) if (gameObject == null)
continue; continue;
var index = (ObjectIndex) gameObject->GameObject.ObjectIndex; var index = (ObjectIndex)gameObject->GameObject.ObjectIndex;
foreach (var type in Enum.GetValues<DrawObjectType>()) foreach (var type in Enum.GetValues<DrawObjectType>())
{ {
@ -93,7 +93,7 @@ public readonly record struct MaterialInfo(ObjectIndex ObjectIndex, DrawObjectTy
continue; continue;
var mtrlHandle = material->MaterialResourceHandle; var mtrlHandle = material->MaterialResourceHandle;
var path = ResolveContext.GetResourceHandlePath((Structs.ResourceHandle*)mtrlHandle); var path = ResolveContext.GetResourceHandlePath((Structs.ResourceHandle*)mtrlHandle);
if (path == needle) if (path == needle)
result.Add(new MaterialInfo(index, type, i, j)); result.Add(new MaterialInfo(index, type, i, j));
} }

View file

@ -2,6 +2,7 @@ using Dalamud.Game.ClientState.Conditions;
using Dalamud.Hooking; using Dalamud.Hooking;
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures; using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using Penumbra.Collections; using Penumbra.Collections;
using Penumbra.Api.Enums; using Penumbra.Api.Enums;
@ -37,6 +38,10 @@ public unsafe class AnimationHookService : IDisposable
_conditions = conditions; _conditions = conditions;
interop.InitializeFromAttributes(this); interop.InitializeFromAttributes(this);
_loadCharacterSoundHook =
interop.HookFromAddress<LoadCharacterSound>(
(nint)FFXIVClientStructs.FFXIV.Client.Game.Character.Character.VfxContainer.MemberFunctionPointers.LoadCharacterSound,
LoadCharacterSoundDetour);
_loadCharacterSoundHook.Enable(); _loadCharacterSoundHook.Enable();
_loadTimelineResourcesHook.Enable(); _loadTimelineResourcesHook.Enable();
@ -113,9 +118,7 @@ public unsafe class AnimationHookService : IDisposable
/// <summary> Characters load some of their voice lines or whatever with this function. </summary> /// <summary> Characters load some of their voice lines or whatever with this function. </summary>
private delegate nint LoadCharacterSound(nint character, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7); private delegate nint LoadCharacterSound(nint character, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7);
// TODO: Use ClientStructs private readonly Hook<LoadCharacterSound> _loadCharacterSoundHook;
[Signature(Sigs.LoadCharacterSound, DetourName = nameof(LoadCharacterSoundDetour))]
private readonly Hook<LoadCharacterSound> _loadCharacterSoundHook = null!;
private nint LoadCharacterSoundDetour(nint container, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7) private nint LoadCharacterSoundDetour(nint container, int unk1, int unk2, nint unk3, ulong unk4, int unk5, int unk6, ulong unk7)
{ {
@ -194,16 +197,18 @@ public unsafe class AnimationHookService : IDisposable
_animationLoadData.Value = last; _animationLoadData.Value = last;
} }
private delegate void SomeActionLoadDelegate(ActionTimelineManager* timelineManager);
/// <summary> Seems to load character actions when zoning or changing class, maybe. </summary> /// <summary> Seems to load character actions when zoning or changing class, maybe. </summary>
[Signature(Sigs.LoadSomeAction, DetourName = nameof(SomeActionLoadDetour))] [Signature(Sigs.LoadSomeAction, DetourName = nameof(SomeActionLoadDetour))]
private readonly Hook<CharacterBaseNoArgumentDelegate> _someActionLoadHook = null!; private readonly Hook<SomeActionLoadDelegate> _someActionLoadHook = null!;
private void SomeActionLoadDetour(nint gameObject) private void SomeActionLoadDetour(ActionTimelineManager* timelineManager)
{ {
using var performance = _performance.Measure(PerformanceType.LoadAction); using var performance = _performance.Measure(PerformanceType.LoadAction);
var last = _animationLoadData.Value; var last = _animationLoadData.Value;
_animationLoadData.Value = _collectionResolver.IdentifyCollection((GameObject*)gameObject, true); _animationLoadData.Value = _collectionResolver.IdentifyCollection((GameObject*)timelineManager->Parent, true);
_someActionLoadHook.Original(gameObject); _someActionLoadHook.Original(timelineManager);
_animationLoadData.Value = last; _animationLoadData.Value = last;
} }