Skip to content

Commit

Permalink
rework server time packet processing (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
marzent committed Mar 17, 2024
1 parent 391b37f commit 2d11f1b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions IINACT/FfxivActPluginWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public partial class FfxivActPluginWrapper : IDisposable
private ISettingsMediator settingsMediator = null!;
private readonly ParseMediator parseMediator;

private readonly IServerTimeProcessor serverTimeProcessor;
private readonly ServerTimeProcessor serverTimeProcessor;
private readonly IReadServerTime readServerTime;
private readonly MobArrayProcessor mobArrayProcessor;
private readonly IZoneMapProcessor zoneMapProcessor;
private readonly CombatantManager combatantManager;
Expand Down Expand Up @@ -99,7 +100,8 @@ public unsafe FfxivActPluginWrapper(
var scanMemory = (ScanMemory)ffxivActPlugin._dataCollection._scanMemory;

processManager = scanMemory._processManager;
serverTimeProcessor = scanMemory._serverTimeProcessor;
serverTimeProcessor = (ServerTimeProcessor)scanMemory._serverTimeProcessor;
readServerTime = serverTimeProcessor._readServerTime;
mobArrayProcessor = (MobArrayProcessor)scanMemory._mobArrayProcessor;
zoneMapProcessor = scanMemory._zoneProcessor;
combatantManager = (CombatantManager)scanMemory._combatantManager;
Expand All @@ -119,7 +121,13 @@ public unsafe FfxivActPluginWrapper(

this.chatGui.ChatMessage += OnChatMessage;
ActGlobals.oFormActMain.BeforeLogLineRead += OFormActMain_BeforeLogLineRead;
Machina.FFXIV.Dalamud.DalamudClient.GetServerTime = () => serverTimeProcessor.ServerTime;
Machina.FFXIV.Dalamud.DalamudClient.GetServerTime = () =>
{
var timestamp = readServerTime.Read();
var seconds = timestamp & 0xFFFFFFFF;
var milliseconds = timestamp >> 32;
return (long)((seconds * 1000) + milliseconds);
};

cancellationTokenSource = new CancellationTokenSource();
scanThread = new Thread(() => ScanMemory(cancellationTokenSource.Token))
Expand Down

0 comments on commit 2d11f1b

Please sign in to comment.