Skip to content

Commit

Permalink
adjust calculation, add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jjolano committed Apr 28, 2022
1 parent f670df9 commit 7599aaf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions XivAlexander/Apps/MainApp/Internal/NetworkTimingHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,16 @@ struct XivAlexander::Apps::MainApp::Internal::NetworkTimingHandler::Implementati
return nowUs + originalWaitUs - latencyUs;

case HighLatencyMitigationMode::SimulateNormalizedRttAndLatency: {
// Server-side focused mode. Attempts to guess the server delay preferably using response time statistics.
// This aims to achieve a similar feel of real low latency play.
const auto rttMinUs = Conn.ApplicationLatencyUs.Min();
description << std::format(" rttMin={}us", rttMinUs);

const auto [rttMeanUs, rttDeviationUs] = Conn.ApplicationLatencyUs.MeanAndDeviation();
description << std::format(" rttAvg={}+{}us", rttMeanUs, rttDeviationUs);

// Estimate latency based on server response time statistics.
auto latencyEstimateUs = ((rttMinUs + rttMeanUs) / 2) - rttDeviationUs - 30000;
auto latencyEstimateUs = ((rttMinUs + rttMeanUs) / 2) - ((rttDeviationUs + 30000) / 2);
latencyEstimateUs = std::max(latencyUs, latencyEstimateUs);
description << std::format(" latEst={}us", latencyEstimateUs);

Expand All @@ -377,7 +379,7 @@ struct XivAlexander::Apps::MainApp::Internal::NetworkTimingHandler::Implementati
}

case HighLatencyMitigationMode::StandardGcdDivision: {
// Client-side focused mode.
// Client-side focused mode. Emphasizes enforced time slices for animation locks, ensuring both consistent and legal gameplay.
const auto srvDelayUs = latencyUs > 0 ? ((rttUs % latencyUs) + (rttUs - latencyUs)) / 2 : rttUs;
description << std::format(" srv={}us", srvDelayUs);

Expand All @@ -393,7 +395,7 @@ struct XivAlexander::Apps::MainApp::Internal::NetworkTimingHandler::Implementati

// Determine best animation lock value.
// Calculate the delay value to add on the original lock time.
// Fallback to latency subtraction if double weaving is not possible.
// Fallback to latency subtraction if multiple weaving is not possible.
auto delay = srvDelayUs;

if(split > 1) {
Expand Down

0 comments on commit 7599aaf

Please sign in to comment.