clear actionqueue on zoneswitch

This commit is contained in:
Stanley Dimant
2022-09-17 13:29:08 +02:00
parent a27fa1a13d
commit 6149d7eb73
6 changed files with 38 additions and 30 deletions

View File

@@ -269,7 +269,7 @@ public class CachedPlayer
ct.ThrowIfCancellationRequested(); ct.ThrowIfCancellationRequested();
if (_ipcManager.CheckGlamourerApi() && !string.IsNullOrEmpty(glamourerData)) if (_ipcManager.CheckGlamourerApi() && !string.IsNullOrEmpty(glamourerData))
{ {
_ipcManager.GlamourerApplyAll(glamourerData, obj: (IntPtr)minionOrMount); _ipcManager.GlamourerApplyAll(glamourerData, (IntPtr)minionOrMount);
} }
else else
{ {
@@ -426,8 +426,8 @@ public class CachedPlayer
{ {
if (!_dalamudUtil.IsPlayerPresent || !_ipcManager.Initialized || !_apiController.IsConnected) return; if (!_dalamudUtil.IsPlayerPresent || !_ipcManager.Initialized || !_apiController.IsConnected) return;
PlayerCharacter = _dalamudUtil.GetPlayerCharacterFromObjectTableByName(PlayerName!)?.Address ?? IntPtr.Zero; var curPlayerCharacter = _dalamudUtil.GetPlayerCharacterFromObjectTableByName(PlayerName!)?.Address ?? IntPtr.Zero;
if (PlayerCharacter == IntPtr.Zero) if (PlayerCharacter == IntPtr.Zero || PlayerCharacter != curPlayerCharacter)
{ {
DisposePlayer(); DisposePlayer();
return; return;

View File

@@ -61,13 +61,12 @@ namespace MareSynchronos.Managers
_penumbraObjectIsRedrawn = pi.GetIpcSubscriber<IntPtr, int, object?>("Penumbra.GameObjectRedrawn"); _penumbraObjectIsRedrawn = pi.GetIpcSubscriber<IntPtr, int, object?>("Penumbra.GameObjectRedrawn");
_penumbraGetMetaManipulations = _penumbraGetMetaManipulations =
pi.GetIpcSubscriber<string>("Penumbra.GetPlayerMetaManipulations"); pi.GetIpcSubscriber<string>("Penumbra.GetPlayerMetaManipulations");
_penumbraSetTemporaryMod = pi.GetIpcSubscriber<string, string, Dictionary<string, string>, string, int,
_glamourerApiVersion = pi.GetIpcSubscriber<int>("Glamourer.ApiVersion"); int>("Penumbra.AddTemporaryMod");
_glamourerGetAllCustomization = pi.GetIpcSubscriber<GameObject?, string>("Glamourer.GetAllCustomizationFromCharacter"); _penumbraCreateTemporaryCollection =
_glamourerApplyAll = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyAllToCharacter"); pi.GetIpcSubscriber<string, string, bool, (int, string)>("Penumbra.CreateTemporaryCollection");
_glamourerApplyOnlyCustomization = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyCustomizationToCharacter"); _penumbraRemoveTemporaryCollection =
_glamourerApplyOnlyEquipment = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyEquipmentToCharacter"); pi.GetIpcSubscriber<string, int>("Penumbra.RemoveTemporaryCollection");
_glamourerRevertCustomization = pi.GetIpcSubscriber<GameObject?, object>("Glamourer.RevertCharacter");
_penumbraGameObjectResourcePathResolved = pi.GetIpcSubscriber<IntPtr, string, string, object?>("Penumbra.GameObjectResourcePathResolved"); _penumbraGameObjectResourcePathResolved = pi.GetIpcSubscriber<IntPtr, string, string, object?>("Penumbra.GameObjectResourcePathResolved");
_penumbraGameObjectResourcePathResolved.Subscribe(ResourceLoaded); _penumbraGameObjectResourcePathResolved.Subscribe(ResourceLoaded);
@@ -75,15 +74,12 @@ namespace MareSynchronos.Managers
_penumbraInit.Subscribe(PenumbraInit); _penumbraInit.Subscribe(PenumbraInit);
_penumbraDispose.Subscribe(PenumbraDispose); _penumbraDispose.Subscribe(PenumbraDispose);
_penumbraSetTemporaryMod = _glamourerApiVersion = pi.GetIpcSubscriber<int>("Glamourer.ApiVersion");
pi _glamourerGetAllCustomization = pi.GetIpcSubscriber<GameObject?, string>("Glamourer.GetAllCustomizationFromCharacter");
.GetIpcSubscriber<string, string, Dictionary<string, string>, string, int, _glamourerApplyAll = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyAllToCharacter");
int>("Penumbra.AddTemporaryMod"); _glamourerApplyOnlyCustomization = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyCustomizationToCharacter");
_glamourerApplyOnlyEquipment = pi.GetIpcSubscriber<string, GameObject?, object>("Glamourer.ApplyOnlyEquipmentToCharacter");
_penumbraCreateTemporaryCollection = _glamourerRevertCustomization = pi.GetIpcSubscriber<GameObject?, object>("Glamourer.RevertCharacter");
pi.GetIpcSubscriber<string, string, bool, (int, string)>("Penumbra.CreateTemporaryCollection");
_penumbraRemoveTemporaryCollection =
pi.GetIpcSubscriber<string, int>("Penumbra.RemoveTemporaryCollection");
_heelsGetApiVersion = pi.GetIpcSubscriber<string>("HeelsPlugin.ApiVersion"); _heelsGetApiVersion = pi.GetIpcSubscriber<string>("HeelsPlugin.ApiVersion");
_heelsGetOffset = pi.GetIpcSubscriber<float>("HeelsPlugin.GetOffset"); _heelsGetOffset = pi.GetIpcSubscriber<float>("HeelsPlugin.GetOffset");
@@ -98,8 +94,14 @@ namespace MareSynchronos.Managers
PenumbraInitialized?.Invoke(); PenumbraInitialized?.Invoke();
} }
this._dalamudUtil = dalamudUtil; _dalamudUtil = dalamudUtil;
_dalamudUtil.FrameworkUpdate += HandleActionQueue; _dalamudUtil.FrameworkUpdate += HandleActionQueue;
_dalamudUtil.ZoneSwitchEnd += ClearActionQueue;
}
private void ClearActionQueue()
{
actionQueue.Clear();
} }
private void ResourceLoaded(IntPtr ptr, string arg1, string arg2) private void ResourceLoaded(IntPtr ptr, string arg1, string arg2)
@@ -178,6 +180,7 @@ namespace MareSynchronos.Managers
Logger.Verbose("Action queue clear or not, disposing"); Logger.Verbose("Action queue clear or not, disposing");
_dalamudUtil.FrameworkUpdate -= HandleActionQueue; _dalamudUtil.FrameworkUpdate -= HandleActionQueue;
_dalamudUtil.ZoneSwitchEnd -= ClearActionQueue;
actionQueue.Clear(); actionQueue.Clear();
_penumbraDispose.Unsubscribe(PenumbraDispose); _penumbraDispose.Unsubscribe(PenumbraDispose);

View File

@@ -46,7 +46,7 @@ public class OnlinePlayerManager : IDisposable
_dalamudUtil.LogIn += DalamudUtilOnLogIn; _dalamudUtil.LogIn += DalamudUtilOnLogIn;
_dalamudUtil.LogOut += DalamudUtilOnLogOut; _dalamudUtil.LogOut += DalamudUtilOnLogOut;
_dalamudUtil.ZoneSwitched += DalamudUtilOnZoneSwitched; _dalamudUtil.ZoneSwitchStart += DalamudUtilOnZoneSwitched;
if (_dalamudUtil.IsLoggedIn) if (_dalamudUtil.IsLoggedIn)
{ {
@@ -145,7 +145,7 @@ public class OnlinePlayerManager : IDisposable
_dalamudUtil.LogIn -= DalamudUtilOnLogIn; _dalamudUtil.LogIn -= DalamudUtilOnLogIn;
_dalamudUtil.LogOut -= DalamudUtilOnLogOut; _dalamudUtil.LogOut -= DalamudUtilOnLogOut;
_dalamudUtil.ZoneSwitched -= DalamudUtilOnZoneSwitched; _dalamudUtil.ZoneSwitchStart -= DalamudUtilOnZoneSwitched;
_dalamudUtil.DelayedFrameworkUpdate -= FrameworkOnUpdate; _dalamudUtil.DelayedFrameworkUpdate -= FrameworkOnUpdate;
} }

View File

@@ -240,8 +240,8 @@ namespace MareSynchronos.Managers
if (cacheDto == null || token.IsCancellationRequested) return; if (cacheDto == null || token.IsCancellationRequested) return;
#if DEBUG #if DEBUG
var json = JsonConvert.SerializeObject(cacheDto, Formatting.Indented); //var json = JsonConvert.SerializeObject(cacheDto, Formatting.Indented);
Logger.Verbose(json); //Logger.Verbose(json);
#endif #endif
if ((LastCreatedCharacterData?.GetHashCode() ?? 0) == cacheDto.GetHashCode()) if ((LastCreatedCharacterData?.GetHashCode() ?? 0) == cacheDto.GetHashCode())

View File

@@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<Authors></Authors> <Authors></Authors>
<Company></Company> <Company></Company>
<Version>0.4.7</Version> <Version>0.4.8</Version>
<Description></Description> <Description></Description>
<Copyright></Copyright> <Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl> <PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -35,7 +35,8 @@ namespace MareSynchronos.Utils
public event ClassJobChanged? ClassJobChanged; public event ClassJobChanged? ClassJobChanged;
private uint? classJobId = 0; private uint? classJobId = 0;
public event FrameworkUpdate? DelayedFrameworkUpdate; public event FrameworkUpdate? DelayedFrameworkUpdate;
public event VoidDelegate? ZoneSwitched; public event VoidDelegate? ZoneSwitchStart;
public event VoidDelegate? ZoneSwitchEnd;
private DateTime _delayedFrameworkUpdateCheck = DateTime.Now; private DateTime _delayedFrameworkUpdateCheck = DateTime.Now;
private bool _sentBetweenAreas = false; private bool _sentBetweenAreas = false;
@@ -74,15 +75,19 @@ namespace MareSynchronos.Utils
{ {
if (!_sentBetweenAreas) if (!_sentBetweenAreas)
{ {
Logger.Debug("Invoking between areas"); Logger.Debug("Zone switch start");
_sentBetweenAreas = true; _sentBetweenAreas = true;
ZoneSwitched?.Invoke(); ZoneSwitchStart?.Invoke();
} }
return; return;
} }
else if (_sentBetweenAreas)
_sentBetweenAreas = false; {
Logger.Debug("Zone switch end");
_sentBetweenAreas = false;
ZoneSwitchEnd?.Invoke();
}
foreach (FrameworkUpdate? frameworkInvocation in (FrameworkUpdate?.GetInvocationList() ?? Array.Empty<FrameworkUpdate>()).Cast<FrameworkUpdate>()) foreach (FrameworkUpdate? frameworkInvocation in (FrameworkUpdate?.GetInvocationList() ?? Array.Empty<FrameworkUpdate>()).Cast<FrameworkUpdate>())
{ {