Merge remote-tracking branch 'origin/master' into net9-rollup

This commit is contained in:
github-actions[bot] 2024-11-15 18:34:17 +00:00
commit 605c3019f6
5 changed files with 32 additions and 26 deletions

View file

@ -11,7 +11,7 @@ jobs:
strategy: strategy:
matrix: matrix:
branches: branches:
- api11 - net9
defaults: defaults:
run: run:

View file

@ -38,11 +38,16 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
private readonly ClientStateAddressResolver address; private readonly ClientStateAddressResolver address;
private readonly Hook<EventFramework.Delegates.SetTerritoryTypeId> setupTerritoryTypeHook; private readonly Hook<EventFramework.Delegates.SetTerritoryTypeId> setupTerritoryTypeHook;
private readonly Hook<UIModule.Delegates.HandlePacket> uiModuleHandlePacketHook; private readonly Hook<UIModule.Delegates.HandlePacket> uiModuleHandlePacketHook;
private readonly Hook<ProcessPacketPlayerSetupDelegate> processPacketPlayerSetupHook;
private readonly Hook<LogoutCallbackInterface.Delegates.OnLogout> onLogoutHook; private readonly Hook<LogoutCallbackInterface.Delegates.OnLogout> onLogoutHook;
[ServiceManager.ServiceDependency]
private readonly Framework framework = Service<Framework>.Get();
[ServiceManager.ServiceDependency] [ServiceManager.ServiceDependency]
private readonly NetworkHandlers networkHandlers = Service<NetworkHandlers>.Get(); private readonly NetworkHandlers networkHandlers = Service<NetworkHandlers>.Get();
private bool lastConditionNone = true;
[ServiceManager.ServiceConstructor] [ServiceManager.ServiceConstructor]
private unsafe ClientState(TargetSigScanner sigScanner, Dalamud dalamud, GameLifecycle lifecycle) private unsafe ClientState(TargetSigScanner sigScanner, Dalamud dalamud, GameLifecycle lifecycle)
@ -60,14 +65,13 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
this.setupTerritoryTypeHook = Hook<EventFramework.Delegates.SetTerritoryTypeId>.FromAddress(setTerritoryTypeAddr, this.SetupTerritoryTypeDetour); this.setupTerritoryTypeHook = Hook<EventFramework.Delegates.SetTerritoryTypeId>.FromAddress(setTerritoryTypeAddr, this.SetupTerritoryTypeDetour);
this.uiModuleHandlePacketHook = Hook<UIModule.Delegates.HandlePacket>.FromAddress((nint)UIModule.StaticVirtualTablePointer->HandlePacket, this.UIModuleHandlePacketDetour); this.uiModuleHandlePacketHook = Hook<UIModule.Delegates.HandlePacket>.FromAddress((nint)UIModule.StaticVirtualTablePointer->HandlePacket, this.UIModuleHandlePacketDetour);
this.processPacketPlayerSetupHook = Hook<ProcessPacketPlayerSetupDelegate>.FromAddress(this.address.ProcessPacketPlayerSetup, this.ProcessPacketPlayerSetupDetour);
this.onLogoutHook = Hook<LogoutCallbackInterface.Delegates.OnLogout>.FromAddress((nint)LogoutCallbackInterface.StaticVirtualTablePointer->OnLogout, this.OnLogoutDetour); this.onLogoutHook = Hook<LogoutCallbackInterface.Delegates.OnLogout>.FromAddress((nint)LogoutCallbackInterface.StaticVirtualTablePointer->OnLogout, this.OnLogoutDetour);
this.framework.Update += this.FrameworkOnOnUpdateEvent;
this.networkHandlers.CfPop += this.NetworkHandlersOnCfPop; this.networkHandlers.CfPop += this.NetworkHandlersOnCfPop;
this.setupTerritoryTypeHook.Enable(); this.setupTerritoryTypeHook.Enable();
this.uiModuleHandlePacketHook.Enable(); this.uiModuleHandlePacketHook.Enable();
this.processPacketPlayerSetupHook.Enable();
this.onLogoutHook.Enable(); this.onLogoutHook.Enable();
} }
@ -171,8 +175,9 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
{ {
this.setupTerritoryTypeHook.Dispose(); this.setupTerritoryTypeHook.Dispose();
this.uiModuleHandlePacketHook.Dispose(); this.uiModuleHandlePacketHook.Dispose();
this.processPacketPlayerSetupHook.Dispose();
this.onLogoutHook.Dispose(); this.onLogoutHook.Dispose();
this.framework.Update -= this.FrameworkOnOnUpdateEvent;
this.networkHandlers.CfPop -= this.NetworkHandlersOnCfPop; this.networkHandlers.CfPop -= this.NetworkHandlersOnCfPop;
} }
@ -255,24 +260,24 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
} }
} }
private unsafe void ProcessPacketPlayerSetupDetour(nint a1, nint packet) private void FrameworkOnOnUpdateEvent(IFramework framework1)
{ {
// Call original first, so everything is set up. var condition = Service<Conditions.Condition>.GetNullable();
this.processPacketPlayerSetupHook.Original(a1, packet);
var gameGui = Service<GameGui>.GetNullable(); var gameGui = Service<GameGui>.GetNullable();
var data = Service<DataManager>.GetNullable();
try if (condition == null || gameGui == null || data == null)
return;
if (condition.Any() && this.lastConditionNone && this.LocalPlayer != null)
{ {
Log.Debug("Login"); Log.Debug("Is login");
this.lastConditionNone = false;
this.Login?.InvokeSafely(); this.Login?.InvokeSafely();
gameGui?.ResetUiHideState(); gameGui.ResetUiHideState();
this.lifecycle.ResetLogout(); this.lifecycle.ResetLogout();
} }
catch (Exception ex)
{
Log.Error(ex, "Exception during ProcessPacketPlayerSetupDetour");
}
} }
private unsafe void OnLogoutDetour(LogoutCallbackInterface* thisPtr, LogoutCallbackInterface.LogoutParams* logoutParams) private unsafe void OnLogoutDetour(LogoutCallbackInterface* thisPtr, LogoutCallbackInterface.LogoutParams* logoutParams)
@ -304,6 +309,7 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
} }
gameGui?.ResetUiHideState(); gameGui?.ResetUiHideState();
this.lastConditionNone = true; // unblock login flag
this.lifecycle.SetLogout(); this.lifecycle.SetLogout();
} }

View file

@ -16,25 +16,25 @@ public struct GamepadInput
/// <summary> /// <summary>
/// Left analogue stick's horizontal value, -99 for left, 99 for right. /// Left analogue stick's horizontal value, -99 for left, 99 for right.
/// </summary> /// </summary>
[FieldOffset(0x88)] [FieldOffset(0x78)]
public int LeftStickX; public int LeftStickX;
/// <summary> /// <summary>
/// Left analogue stick's vertical value, -99 for down, 99 for up. /// Left analogue stick's vertical value, -99 for down, 99 for up.
/// </summary> /// </summary>
[FieldOffset(0x8C)] [FieldOffset(0x7C)]
public int LeftStickY; public int LeftStickY;
/// <summary> /// <summary>
/// Right analogue stick's horizontal value, -99 for left, 99 for right. /// Right analogue stick's horizontal value, -99 for left, 99 for right.
/// </summary> /// </summary>
[FieldOffset(0x90)] [FieldOffset(0x80)]
public int RightStickX; public int RightStickX;
/// <summary> /// <summary>
/// Right analogue stick's vertical value, -99 for down, 99 for up. /// Right analogue stick's vertical value, -99 for down, 99 for up.
/// </summary> /// </summary>
[FieldOffset(0x94)] [FieldOffset(0x84)]
public int RightStickY; public int RightStickY;
/// <summary> /// <summary>
@ -43,7 +43,7 @@ public struct GamepadInput
/// <remarks> /// <remarks>
/// This is a bitfield. /// This is a bitfield.
/// </remarks> /// </remarks>
[FieldOffset(0x98)] [FieldOffset(0x88)]
public ushort ButtonsRaw; public ushort ButtonsRaw;
/// <summary> /// <summary>
@ -52,7 +52,7 @@ public struct GamepadInput
/// <remarks> /// <remarks>
/// This is a bitfield. /// This is a bitfield.
/// </remarks> /// </remarks>
[FieldOffset(0x9C)] [FieldOffset(0x8C)]
public ushort ButtonsPressed; public ushort ButtonsPressed;
/// <summary> /// <summary>
@ -61,7 +61,7 @@ public struct GamepadInput
/// <remarks> /// <remarks>
/// This is a bitfield. /// This is a bitfield.
/// </remarks> /// </remarks>
[FieldOffset(0xA0)] [FieldOffset(0x90)]
public ushort ButtonsReleased; public ushort ButtonsReleased;
/// <summary> /// <summary>
@ -70,6 +70,6 @@ public struct GamepadInput
/// <remarks> /// <remarks>
/// This is a bitfield. /// This is a bitfield.
/// </remarks> /// </remarks>
[FieldOffset(0xA4)] [FieldOffset(0x94)]
public ushort ButtonsRepeat; public ushort ButtonsRepeat;
} }

View file

@ -28,7 +28,7 @@ internal class JobGauges : IServiceType, IJobGauges
} }
/// <inheritdoc/> /// <inheritdoc/>
public unsafe IntPtr Address => (nint)(&CSJobGaugeManager.Instance()->CurrentGauge); public unsafe IntPtr Address => (nint)(CSJobGaugeManager.Instance()->CurrentGauge);
/// <inheritdoc/> /// <inheritdoc/>
public T Get<T>() where T : JobGaugeBase public T Get<T>() where T : JobGaugeBase

@ -1 +1 @@
Subproject commit 679b5353cd61baa03b26d95efcac059f8e29b141 Subproject commit fca10adcab3911c1be79cb0753987a2a02b7e058