mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add IGameNetwork (#1284)
Co-authored-by: goat <16760685+goaaats@users.noreply.github.com>
This commit is contained in:
parent
2677964fc5
commit
a3787498c9
2 changed files with 32 additions and 12 deletions
|
|
@ -5,6 +5,7 @@ using Dalamud.Configuration.Internal;
|
||||||
using Dalamud.Hooking;
|
using Dalamud.Hooking;
|
||||||
using Dalamud.IoC;
|
using Dalamud.IoC;
|
||||||
using Dalamud.IoC.Internal;
|
using Dalamud.IoC.Internal;
|
||||||
|
using Dalamud.Plugin.Services;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
|
|
||||||
|
|
@ -16,7 +17,10 @@ namespace Dalamud.Game.Network;
|
||||||
[PluginInterface]
|
[PluginInterface]
|
||||||
[InterfaceVersion("1.0")]
|
[InterfaceVersion("1.0")]
|
||||||
[ServiceManager.BlockingEarlyLoadedService]
|
[ServiceManager.BlockingEarlyLoadedService]
|
||||||
public sealed class GameNetwork : IDisposable, IServiceType
|
#pragma warning disable SA1015
|
||||||
|
[ResolveVia<IGameNetwork>]
|
||||||
|
#pragma warning restore SA1015
|
||||||
|
public sealed class GameNetwork : IDisposable, IServiceType, IGameNetwork
|
||||||
{
|
{
|
||||||
private readonly GameNetworkAddressResolver address;
|
private readonly GameNetworkAddressResolver address;
|
||||||
private readonly Hook<ProcessZonePacketDownDelegate> processZonePacketDownHook;
|
private readonly Hook<ProcessZonePacketDownDelegate> processZonePacketDownHook;
|
||||||
|
|
@ -47,16 +51,6 @@ public sealed class GameNetwork : IDisposable, IServiceType
|
||||||
this.processZonePacketUpHook = Hook<ProcessZonePacketUpDelegate>.FromAddress(this.address.ProcessZonePacketUp, this.ProcessZonePacketUpDetour);
|
this.processZonePacketUpHook = Hook<ProcessZonePacketUpDelegate>.FromAddress(this.address.ProcessZonePacketUp, this.ProcessZonePacketUpDetour);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The delegate type of a network message event.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dataPtr">The pointer to the raw data.</param>
|
|
||||||
/// <param name="opCode">The operation ID code.</param>
|
|
||||||
/// <param name="sourceActorId">The source actor ID.</param>
|
|
||||||
/// <param name="targetActorId">The taret actor ID.</param>
|
|
||||||
/// <param name="direction">The direction of the packed.</param>
|
|
||||||
public delegate void OnNetworkMessageDelegate(IntPtr dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction);
|
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
[UnmanagedFunctionPointer(CallingConvention.ThisCall)]
|
||||||
private delegate void ProcessZonePacketDownDelegate(IntPtr a, uint targetId, IntPtr dataPtr);
|
private delegate void ProcessZonePacketDownDelegate(IntPtr a, uint targetId, IntPtr dataPtr);
|
||||||
|
|
||||||
|
|
@ -66,7 +60,7 @@ public sealed class GameNetwork : IDisposable, IServiceType
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event that is called when a network message is sent/received.
|
/// Event that is called when a network message is sent/received.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event OnNetworkMessageDelegate NetworkMessage;
|
public event IGameNetwork.OnNetworkMessageDelegate NetworkMessage;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispose of managed and unmanaged resources.
|
/// Dispose of managed and unmanaged resources.
|
||||||
|
|
|
||||||
26
Dalamud/Plugin/Services/IGameNetwork.cs
Normal file
26
Dalamud/Plugin/Services/IGameNetwork.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
using Dalamud.Game.Network;
|
||||||
|
|
||||||
|
namespace Dalamud.Plugin.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class handles interacting with game network events.
|
||||||
|
/// </summary>
|
||||||
|
public interface IGameNetwork
|
||||||
|
{
|
||||||
|
// TODO(v9): we shouldn't be passing pointers to the actual data here
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The delegate type of a network message event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataPtr">The pointer to the raw data.</param>
|
||||||
|
/// <param name="opCode">The operation ID code.</param>
|
||||||
|
/// <param name="sourceActorId">The source actor ID.</param>
|
||||||
|
/// <param name="targetActorId">The taret actor ID.</param>
|
||||||
|
/// <param name="direction">The direction of the packed.</param>
|
||||||
|
public delegate void OnNetworkMessageDelegate(nint dataPtr, ushort opCode, uint sourceActorId, uint targetActorId, NetworkMessageDirection direction);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event that is called when a network message is sent/received.
|
||||||
|
/// </summary>
|
||||||
|
public event OnNetworkMessageDelegate NetworkMessage;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue