File tree Expand file tree Collapse file tree
Core/GameEngine/Source/GameNetwork Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2626
2727#include " PreRTS.h" // This must go first in EVERY cpp file in the GameEngine
2828
29+ #include < numeric>
30+
2931#include " GameNetwork/FrameMetrics.h"
3032#include " GameClient/Display.h"
3133#include " GameNetwork/networkutil.h"
@@ -105,9 +107,9 @@ void FrameMetrics::processLatencyResponse(UnsignedInt frame) {
105107 time_t timeDiff = curTime - m_pendingLatencies[pendingIndex];
106108
107109 Int latencyListIndex = frame % TheGlobalData->m_networkLatencyHistoryLength ;
108- m_averageLatency -= m_latencyList[latencyListIndex] / TheGlobalData->m_networkLatencyHistoryLength ;
109110 m_latencyList[latencyListIndex] = (Real)timeDiff / (Real)1000 ; // convert to seconds from milliseconds.
110- m_averageLatency += m_latencyList[latencyListIndex] / TheGlobalData->m_networkLatencyHistoryLength ;
111+ const Real latencySum = std::accumulate (m_latencyList, m_latencyList + TheGlobalData->m_networkLatencyHistoryLength , 0 .0f );
112+ m_averageLatency = latencySum / (Real)TheGlobalData->m_networkLatencyHistoryLength ;
111113
112114 if (frame % 16 == 0 ) {
113115// DEBUG_LOG(("ConnectionManager::processFrameInfoAck - average latency = %f", m_averageLatency));
You can’t perform that action at this time.
0 commit comments