mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-25 18:09:17 +01:00
Merge branch 'master' of github.com:goatcorp/Dalamud
This commit is contained in:
commit
b24cadf2d8
5 changed files with 13 additions and 31 deletions
|
|
@ -37,7 +37,6 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
|
|||
|
||||
private readonly GameLifecycle lifecycle;
|
||||
private readonly ClientStateAddressResolver address;
|
||||
private readonly Hook<HandleZoneInitPacketDelegate> handleZoneInitPacketHook;
|
||||
private readonly Hook<UIModule.Delegates.HandlePacket> uiModuleHandlePacketHook;
|
||||
private readonly Hook<SetCurrentInstanceDelegate> setCurrentInstanceHook;
|
||||
|
||||
|
|
@ -72,13 +71,11 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
|
|||
|
||||
this.ClientLanguage = (ClientLanguage)dalamud.StartInfo.Language;
|
||||
|
||||
this.handleZoneInitPacketHook = Hook<HandleZoneInitPacketDelegate>.FromAddress(this.AddressResolver.HandleZoneInitPacket, this.HandleZoneInitPacketDetour);
|
||||
this.uiModuleHandlePacketHook = Hook<UIModule.Delegates.HandlePacket>.FromAddress((nint)UIModule.StaticVirtualTablePointer->HandlePacket, this.UIModuleHandlePacketDetour);
|
||||
this.setCurrentInstanceHook = Hook<SetCurrentInstanceDelegate>.FromAddress(this.AddressResolver.SetCurrentInstance, this.SetCurrentInstanceDetour);
|
||||
|
||||
this.networkHandlers.CfPop += this.NetworkHandlersOnCfPop;
|
||||
|
||||
this.handleZoneInitPacketHook.Enable();
|
||||
this.uiModuleHandlePacketHook.Enable();
|
||||
this.setCurrentInstanceHook.Enable();
|
||||
|
||||
|
|
@ -271,7 +268,6 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
|
|||
/// </summary>
|
||||
void IInternalDisposableService.DisposeService()
|
||||
{
|
||||
this.handleZoneInitPacketHook.Dispose();
|
||||
this.uiModuleHandlePacketHook.Dispose();
|
||||
this.onLogoutHook.Dispose();
|
||||
this.setCurrentInstanceHook.Dispose();
|
||||
|
|
@ -294,23 +290,6 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
|
|||
this.framework.Update += this.OnFrameworkUpdate;
|
||||
}
|
||||
|
||||
private void HandleZoneInitPacketDetour(nint a1, uint localPlayerEntityId, nint packet, byte type)
|
||||
{
|
||||
this.handleZoneInitPacketHook.Original(a1, localPlayerEntityId, packet, type);
|
||||
|
||||
try
|
||||
{
|
||||
var eventArgs = ZoneInitEventArgs.Read(packet);
|
||||
Log.Debug($"ZoneInit: {eventArgs}");
|
||||
this.ZoneInit?.InvokeSafely(eventArgs);
|
||||
this.TerritoryType = (ushort)eventArgs.TerritoryType.RowId;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Exception during ZoneInit");
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void UIModuleHandlePacketDetour(
|
||||
UIModule* thisPtr, UIModulePacketType type, uint uintParam, void* packet)
|
||||
{
|
||||
|
|
@ -356,6 +335,15 @@ internal sealed class ClientState : IInternalDisposableService, IClientState
|
|||
|
||||
break;
|
||||
}
|
||||
|
||||
case (UIModulePacketType)5: // TODO: Use UIModulePacketType.InitZone when available
|
||||
{
|
||||
var eventArgs = ZoneInitEventArgs.Read((nint)packet);
|
||||
Log.Debug($"ZoneInit: {eventArgs}");
|
||||
this.ZoneInit?.InvokeSafely(eventArgs);
|
||||
this.TerritoryType = (ushort)eventArgs.TerritoryType.RowId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,6 @@ internal sealed class ClientStateAddressResolver : BaseAddressResolver
|
|||
|
||||
// Functions
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the method that handles the ZoneInit packet.
|
||||
/// </summary>
|
||||
public nint HandleZoneInitPacket { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the address of the method that sets the current public instance.
|
||||
/// </summary>
|
||||
|
|
@ -37,7 +32,6 @@ internal sealed class ClientStateAddressResolver : BaseAddressResolver
|
|||
/// <param name="sig">The signature scanner to facilitate setup.</param>
|
||||
protected override void Setup64Bit(ISigScanner sig)
|
||||
{
|
||||
this.HandleZoneInitPacket = sig.ScanText("E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 44 0F B6 45");
|
||||
this.SetCurrentInstance = sig.ScanText("E8 ?? ?? ?? ?? 0F B6 55 ?? 48 8D 0D ?? ?? ?? ?? C0 EA"); // NetworkModuleProxy.SetCurrentInstance
|
||||
|
||||
// These resolve to fixed offsets only, without the base address added in, so GetStaticAddressFromSig() can't be used.
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class ZoneInitEventArgs : EventArgs
|
|||
eventArgs.ContentFinderCondition = dataManager.GetExcelSheet<ContentFinderCondition>().GetRow(*(ushort*)(packet + 0x06));
|
||||
eventArgs.Weather = dataManager.GetExcelSheet<Weather>().GetRow(*(byte*)(packet + 0x10));
|
||||
|
||||
const int NumFestivals = 4;
|
||||
const int NumFestivals = 8;
|
||||
eventArgs.ActiveFestivals = new Festival[NumFestivals];
|
||||
eventArgs.ActiveFestivalPhases = new ushort[NumFestivals];
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ public class ZoneInitEventArgs : EventArgs
|
|||
// but it's unclear why they exist as separate entries and why they would be different.
|
||||
for (var i = 0; i < NumFestivals; i++)
|
||||
{
|
||||
eventArgs.ActiveFestivals[i] = dataManager.GetExcelSheet<Festival>().GetRow(*(ushort*)(packet + 0x2E + (i * 2)));
|
||||
eventArgs.ActiveFestivals[i] = dataManager.GetExcelSheet<Festival>().GetRow(*(ushort*)(packet + 0x26 + (i * 2)));
|
||||
eventArgs.ActiveFestivalPhases[i] = *(ushort*)(packet + 0x36 + (i * 2));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit faf803a76813511768d45c137a543aaacf5420b8
|
||||
Subproject commit 63c2596738d2807d1d5ddf13c4dddbe0840d4df4
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit 7d3f90e61732df6aef63196d1abaab1074f6f3c9
|
||||
Subproject commit d6ff8cf46c7e341989843c28c7550f8d50bee851
|
||||
Loading…
Add table
Add a link
Reference in a new issue