Fix some issues with Crests

This commit is contained in:
Ottermandias 2024-11-27 23:28:56 +01:00
parent 66ed721105
commit 533c53fd8d
4 changed files with 28 additions and 3 deletions

View file

@ -139,7 +139,7 @@ public class Glamourer : IDalamudPlugin
ReadOnlySpan<string> relevantPlugins = ReadOnlySpan<string> relevantPlugins =
[ [
"Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge", "Penumbra", "MareSynchronos", "CustomizePlus", "SimpleHeels", "VfxEditor", "heliosphere-plugin", "Ktisis", "Brio", "DynamicBridge",
"LoporritSync", "LoporritSync", "GagSpeak", "RoleplayingVoiceDalamud",
]; ];
var plugins = _services.GetService<IDalamudPluginInterface>().InstalledPlugins var plugins = _services.GetService<IDalamudPluginInterface>().InstalledPlugins
.GroupBy(p => p.InternalName) .GroupBy(p => p.InternalName)

View file

@ -2,6 +2,7 @@
using Dalamud.Plugin.Services; using Dalamud.Plugin.Services;
using Dalamud.Utility.Signatures; using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.Game.Character;
using FFXIVClientStructs.FFXIV.Client.Game.Event;
using FFXIVClientStructs.FFXIV.Client.Graphics.Scene; using FFXIVClientStructs.FFXIV.Client.Graphics.Scene;
using OtterGui.Classes; using OtterGui.Classes;
using Penumbra.GameData; using Penumbra.GameData;
@ -37,6 +38,7 @@ public sealed unsafe class CrestService : EventWrapperRef3<Actor, CrestFlag, boo
_humanSetFreeCompanyCrestVisibleOnSlot.Enable(); _humanSetFreeCompanyCrestVisibleOnSlot.Enable();
_weaponSetFreeCompanyCrestVisibleOnSlot.Enable(); _weaponSetFreeCompanyCrestVisibleOnSlot.Enable();
_crestChangeHook.Enable(); _crestChangeHook.Enable();
_crestChangeCallerHook.Enable();
} }
public void UpdateCrests(Actor gameObject, CrestFlag flags) public void UpdateCrests(Actor gameObject, CrestFlag flags)
@ -60,6 +62,7 @@ public sealed unsafe class CrestService : EventWrapperRef3<Actor, CrestFlag, boo
_humanSetFreeCompanyCrestVisibleOnSlot.Dispose(); _humanSetFreeCompanyCrestVisibleOnSlot.Dispose();
_weaponSetFreeCompanyCrestVisibleOnSlot.Dispose(); _weaponSetFreeCompanyCrestVisibleOnSlot.Dispose();
_crestChangeHook.Dispose(); _crestChangeHook.Dispose();
_crestChangeCallerHook.Dispose();
} }
private delegate void CrestChangeDelegate(DrawDataContainer* container, byte crestFlags); private delegate void CrestChangeDelegate(DrawDataContainer* container, byte crestFlags);
@ -83,6 +86,28 @@ public sealed unsafe class CrestService : EventWrapperRef3<Actor, CrestFlag, boo
_crestChangeHook.Original(container, crestFlags); _crestChangeHook.Original(container, crestFlags);
} }
[Signature(Sigs.CrestChangeCaller, DetourName = nameof(CrestChangeCallerDetour))]
private readonly Hook<CrestChangeCallerDelegate> _crestChangeCallerHook = null!;
private delegate void CrestChangeCallerDelegate(DrawDataContainer* container, byte* data);
private void CrestChangeCallerDetour(DrawDataContainer* container, byte* data)
{
var actor = (Actor)container->OwnerObject;
ref var flags = ref data[16];
foreach (var slot in CrestExtensions.AllRelevantSet)
{
var newValue = ((CrestFlag)flags).HasFlag(slot);
Invoke(actor, slot, ref newValue);
flags = (byte)(newValue ? flags | (byte)slot : flags & (byte)~slot);
}
Glamourer.Log.Verbose(
$"Called inlined CrestChange via CrestChangeCaller on {(ulong)container:X} with {(flags & 0x1F):X} and prior flags {actor.CrestBitfield}.");
using var _ = _inUpdate.EnterMethod();
_crestChangeCallerHook.Original(container, data);
}
public static bool GetModelCrest(Actor gameObject, CrestFlag slot) public static bool GetModelCrest(Actor gameObject, CrestFlag slot)
{ {
if (!gameObject.IsCharacter) if (!gameObject.IsCharacter)

View file

@ -18,7 +18,7 @@ public class ModSettingApplier(PenumbraService penumbra, Configuration config, O
if (!objects.TryGetValue(state.Identifier, out var data)) if (!objects.TryGetValue(state.Identifier, out var data))
{ {
Glamourer.Log.Verbose( Glamourer.Log.Verbose(
$"[Mod Applier] No mod settings applied because no actor for {state.Identifier} could be found to associate collection."); $"[Mod Applier] No mod settings applied because no actor for {state.Identifier.Incognito(null)} could be found to associate collection.");
return; return;
} }

@ -1 +1 @@
Subproject commit 79d8d782b3b454a41f7f87f398806ec4d08d485f Subproject commit cceebd89a19e27ac843b0a7d17d3c2bb41c77367