From 1af317f93f5bbdc2de72d8f2535ef6626e468538 Mon Sep 17 00:00:00 2001 From: Soreepeong Date: Sat, 13 Feb 2021 04:40:51 +0900 Subject: [PATCH] Fix animation lock base time, in case for some reason latency spikes above 500ms --- .../App_Feature_AnimationLockLatencyHandler.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/XivAlexander/App_Feature_AnimationLockLatencyHandler.cpp b/XivAlexander/App_Feature_AnimationLockLatencyHandler.cpp index 5ba1067c..52f178f3 100644 --- a/XivAlexander/App_Feature_AnimationLockLatencyHandler.cpp +++ b/XivAlexander/App_Feature_AnimationLockLatencyHandler.cpp @@ -55,9 +55,14 @@ class App::Feature::AnimationLockLatencyHandler::Internals { const auto& actionRequest = pMessage->Data.IPC.Data.C2S_ActionRequest; m_pendingActions.emplace_back(actionRequest); - // if latest action request has been made after last animation lock end time, reset animation lock base time - if (m_pendingActions.back().RequestTimestamp > m_lastAnimationLockEndsAt) - m_lastAnimationLockEndsAt = m_pendingActions.back().RequestTimestamp; + // If somehow latest action request has been made before last animation lock end time, keep it. + // Otherwise... + if (m_pendingActions.back().RequestTimestamp > m_lastAnimationLockEndsAt) { + + // If there was no action queued to begin with before the current one, update the base lock time to now. + if (m_pendingActions.size() == 1) + m_lastAnimationLockEndsAt = m_pendingActions.back().RequestTimestamp; + } Misc::Logger::GetLogger().Format( "C2S_ActionRequest: actionId=%04x sequence=%04x", @@ -157,7 +162,7 @@ class App::Feature::AnimationLockLatencyHandler::Internals { } else if (pMessage->Data.IPC.SubType == config.S2C_ActorControlSelf) { const auto& actorControlSelf = pMessage->Data.IPC.Data.S2C_ActorControlSelf; - // Latest action request has been rejected from server. + // Oldest action request has been rejected from server. if (actorControlSelf.Category == S2C_ActorControlSelfCategory::ActionRejected) { const auto& rollback = actorControlSelf.Rollback; @@ -177,7 +182,7 @@ class App::Feature::AnimationLockLatencyHandler::Internals { } else if (pMessage->Data.IPC.SubType == config.S2C_ActorControl) { const auto& actorControl = pMessage->Data.IPC.Data.S2C_ActorControl; - // The server has cancelled a cast in progress. + // The server has cancelled an oldest action (which is a cast) in progress. if (actorControl.Category == S2C_ActorControlCategory::CancelCast) { const auto& cancelCast = actorControl.CancelCast;