mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-14 20:54:17 +01:00
Fix leaking a hook?
This commit is contained in:
parent
9218ede11d
commit
06299d1966
4 changed files with 7 additions and 4 deletions
|
|
@ -17,7 +17,7 @@ namespace Glamourer.Interop;
|
||||||
/// Changes in Race, body type or Gender are probably ignored.
|
/// Changes in Race, body type or Gender are probably ignored.
|
||||||
/// This operates on draw objects, not game objects.
|
/// This operates on draw objects, not game objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe class ChangeCustomizeService : EventWrapper<Action<Model, Ref<Customize>>, ChangeCustomizeService.Priority>
|
public unsafe class ChangeCustomizeService : EventWrapper<Action<Model, Ref<Customize>>, ChangeCustomizeService.Priority>, IDisposable
|
||||||
{
|
{
|
||||||
private readonly PenumbraReloaded _penumbraReloaded;
|
private readonly PenumbraReloaded _penumbraReloaded;
|
||||||
private readonly IGameInteropProvider _interop;
|
private readonly IGameInteropProvider _interop;
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,11 @@ public unsafe class InventoryService : IDisposable
|
||||||
public InventoryService(MovedEquipment @event, IGameInteropProvider interop)
|
public InventoryService(MovedEquipment @event, IGameInteropProvider interop)
|
||||||
{
|
{
|
||||||
_event = @event;
|
_event = @event;
|
||||||
|
|
||||||
_moveItemHook = interop.HookFromAddress<MoveItemDelegate>((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour);
|
_moveItemHook = interop.HookFromAddress<MoveItemDelegate>((nint)InventoryManager.MemberFunctionPointers.MoveItemSlot, MoveItemDetour);
|
||||||
_equipGearsetHook =
|
_equipGearsetHook =
|
||||||
interop.HookFromAddress<EquipGearsetDelegate>((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour);
|
interop.HookFromAddress<EquipGearsetDelegate>((nint)RaptureGearsetModule.MemberFunctionPointers.EquipGearset, EquipGearSetDetour);
|
||||||
|
|
||||||
_moveItemHook.Enable();
|
_moveItemHook.Enable();
|
||||||
_equipGearsetHook.Enable();
|
_equipGearsetHook.Enable();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ public unsafe class ScalingService : IDisposable
|
||||||
_setupOrnamentHook = interop.HookFromAddress<SetupOrnament>((nint)Ornament.MemberFunctionPointers.SetupOrnament, SetupOrnamentDetour);
|
_setupOrnamentHook = interop.HookFromAddress<SetupOrnament>((nint)Ornament.MemberFunctionPointers.SetupOrnament, SetupOrnamentDetour);
|
||||||
_calculateHeightHook =
|
_calculateHeightHook =
|
||||||
interop.HookFromAddress<CalculateHeight>((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour);
|
interop.HookFromAddress<CalculateHeight>((nint)Character.MemberFunctionPointers.CalculateHeight, CalculateHeightDetour);
|
||||||
|
|
||||||
_setupMountHook.Enable();
|
_setupMountHook.Enable();
|
||||||
_setupOrnamentHook.Enable();
|
_setupOrnamentHook.Enable();
|
||||||
_placeMinionHook.Enable();
|
_placeMinionHook.Enable();
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class VisorService : IDisposable
|
||||||
if (oldState == on)
|
if (oldState == on)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SetupVisorHook(human, human.GetArmor(EquipSlot.Head).Set.Id, on);
|
SetupVisorDetour(human, human.GetArmor(EquipSlot.Head).Set.Id, on);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ public class VisorService : IDisposable
|
||||||
Glamourer.Log.Excessive(
|
Glamourer.Log.Excessive(
|
||||||
$"[SetVisorState] Invoked from game on 0x{human:X} switching to {on} (original {originalOn}).");
|
$"[SetVisorState] Invoked from game on 0x{human:X} switching to {on} (original {originalOn}).");
|
||||||
|
|
||||||
SetupVisorHook(human, modelId, on);
|
SetupVisorDetour((Model)human, modelId, on);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -70,7 +70,7 @@ public class VisorService : IDisposable
|
||||||
/// So we wrap a manual change of that flag with the function call.
|
/// So we wrap a manual change of that flag with the function call.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||||
private unsafe void SetupVisorHook(Model human, ushort modelId, bool on)
|
private unsafe void SetupVisorDetour(Model human, ushort modelId, bool on)
|
||||||
{
|
{
|
||||||
human.AsCharacterBase->VisorToggled = on;
|
human.AsCharacterBase->VisorToggled = on;
|
||||||
_setupVisorHook.Original(human.Address, modelId, on);
|
_setupVisorHook.Original(human.Address, modelId, on);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue